Skip to content

Commit

Permalink
zio#679 Clean up FunctionDefSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahotoole committed May 26, 2022
1 parent 8857470 commit f9d4521
Showing 1 changed file with 12 additions and 56 deletions.
68 changes: 12 additions & 56 deletions mysql/src/test/scala/zio/sql/mysql/FunctionDefSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package zio.sql.mysql
import zio.Cause
import zio.test._
import zio.test.Assertion._
import java.time.LocalDate

import java.time.LocalDate
import java.time.{ LocalTime, ZoneId }
import java.time.format.DateTimeFormatter

Expand All @@ -22,11 +22,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
// FIXME: lower with string literal should not refer to a column name
// See: https://www.w3schools.com/sql/trymysql.asp?filename=trysql_func_mysql_lower
Expand All @@ -51,11 +47,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("abs") {
val query = select(Abs(-32.0))
Expand All @@ -64,11 +56,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("crc32") {
val query = select(Crc32("MySQL")) from customers
Expand All @@ -77,11 +65,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("degrees") {
val query = select(Degrees(Math.PI)) from customers
Expand All @@ -90,11 +74,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("log2") {
val query = select(Log2(8d)) from customers
Expand All @@ -103,11 +83,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("log10") {
val query = select(Log10(1000000d)) from customers
Expand All @@ -116,11 +92,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("now") {
val timestampFormatter =
Expand All @@ -146,11 +118,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("current_date") {
val query = select(CurrentDate)
Expand All @@ -159,11 +127,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("maketime") {
val query = select(MakeTime(12, 15, 30.5)) from customers
Expand All @@ -172,11 +136,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
},
test("pi") {
val query = select(Pi) from customers
Expand All @@ -185,11 +145,7 @@ object FunctionDefSpec extends MysqlRunnableSpec with ShopSchema {

val testResult = execute(query)

val assertion = for {
r <- testResult.runCollect
} yield assert(r.head)(equalTo(expected))

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(testResult.runHead.some)(equalTo(expected))
}
)
}

0 comments on commit f9d4521

Please sign in to comment.