Skip to content

Commit

Permalink
test: correct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigoriiBerezin committed Apr 29, 2024
1 parent b116754 commit d83b2e0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mysql/src/test/resources/shop_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ values
('784426a5-b90a-4759-afbb-571b7a0ba35e', 'Mila', 'Paterso', true, '1990-11-16'),
('df8215a2-d5fd-4c6c-9984-801a1b3a2a0b', 'Alana', 'Murray', true, '1995-11-12'),
('636ae137-5b1a-4c8c-b11f-c47c624d9cdc', 'Jose', 'Wiggins', false, '1987-03-23'),
('d4f6c156-20ac-4d27-8ced-535bf4315ebc', 'Robert', 'Rupert', false, '1998-06-11');
('d4f6c156-20ac-4d27-8ced-535bf4315ebc', 'Robert', 'Rupert', true, '1998-06-11');

insert into products
(id, name, description, image_url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ object CommonFunctionDefSpec extends MysqlRunnableSpec with Jdbc {
"RonaldRonaldRussell",
"TerrenceTerrenceNoel",
"MilaMilaPaterso",
"RobertRobertRupert",
"AlanaAlanaMurray",
"JoseJoseWiggins"
)
Expand All @@ -53,6 +54,7 @@ object CommonFunctionDefSpec extends MysqlRunnableSpec with Jdbc {
"Person: Ronald Russell",
"Person: Terrence Noel",
"Person: Mila Paterso",
"Person: Robert Rupert",
"Person: Alana Murray",
"Person: Jose Wiggins"
)
Expand All @@ -70,6 +72,7 @@ object CommonFunctionDefSpec extends MysqlRunnableSpec with Jdbc {
"Name: Ronald and Surname: Russell",
"Name: Terrence and Surname: Noel",
"Name: Mila and Surname: Paterso",
"Name: Robert and Surname: Rupert",
"Name: Alana and Surname: Murray",
"Name: Jose and Surname: Wiggins"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import zio.test.Assertion._
import zio.test._

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

object CustomFunctionDefSpec extends MysqlRunnableSpec with Jdbc {
Expand Down
12 changes: 9 additions & 3 deletions mysql/src/test/scala/zio/sql/mysql/MysqlModuleSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ object MysqlModuleSpec extends MysqlRunnableSpec {

val query = select(customerId, fName, lName, dob) from customers

println(renderRead(query))

val expected =
Seq(
Customer(
Expand Down Expand Up @@ -112,6 +110,12 @@ object MysqlModuleSpec extends MysqlRunnableSpec {
"Jose",
"Wiggins",
LocalDate.parse("1987-03-23")
),
Customer(
UUID.fromString("d4f6c156-20ac-4d27-8ced-535bf4315ebc"),
"Robert",
"Rupert",
LocalDate.parse("1998-06-11")
)
)

Expand Down Expand Up @@ -182,6 +186,7 @@ object MysqlModuleSpec extends MysqlRunnableSpec {
UUID.fromString("60b01fc9-c902-4468-8d49-3c0f989def37"),
UUID.fromString("f76c9ace-be07-4bf3-bd4c-4a9c62882e64"),
UUID.fromString("784426a5-b90a-4759-afbb-571b7a0ba35e"),
UUID.fromString("d4f6c156-20ac-4d27-8ced-535bf4315ebc"),
UUID.fromString("df8215a2-d5fd-4c6c-9984-801a1b3a2a0b"),
UUID.fromString("636ae137-5b1a-4c8c-b11f-c47c624d9cdc")
)
Expand All @@ -196,6 +201,7 @@ object MysqlModuleSpec extends MysqlRunnableSpec {
UUID.fromString("60b01fc9-c902-4468-8d49-3c0f989def37"),
UUID.fromString("f76c9ace-be07-4bf3-bd4c-4a9c62882e64"),
UUID.fromString("784426a5-b90a-4759-afbb-571b7a0ba35e"),
UUID.fromString("d4f6c156-20ac-4d27-8ced-535bf4315ebc"),
UUID.fromString("df8215a2-d5fd-4c6c-9984-801a1b3a2a0b"),
UUID.fromString("636ae137-5b1a-4c8c-b11f-c47c624d9cdc")
)
Expand All @@ -211,7 +217,7 @@ object MysqlModuleSpec extends MysqlRunnableSpec {

for {
r <- execute(query).runCollect
} yield assertTrue(r.head == 5L)
} yield assertTrue(r.head == 6L)
},
test("Can select from joined tables (inner join)") {
val query = select(fName, lName, orderDate) from (customers join orders).on(
Expand Down
6 changes: 3 additions & 3 deletions mysql/src/test/scala/zio/sql/mysql/TransactionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object TransactionSpec extends MysqlRunnableSpec with Jdbc {

val assertion =
result
.map(count => assertTrue(count == 5))
.map(count => assertTrue(count == 6))
.orDie

assertion.mapErrorCause(cause => Cause.stackless(cause.untraced))
Expand All @@ -48,7 +48,7 @@ object TransactionSpec extends MysqlRunnableSpec with Jdbc {
remainingCustomersCount <- execute(query).map(identity[UUID](_)).runCount
} yield (allCustomersCount, remainingCustomersCount))

assertZIO(result)(equalTo((5L, 5L))).mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(result)(equalTo((6L, 6L))).mapErrorCause(cause => Cause.stackless(cause.untraced))
},
test("Transaction succeeded and deleted rows") {
val query = select(customerId) from customers
Expand All @@ -62,7 +62,7 @@ object TransactionSpec extends MysqlRunnableSpec with Jdbc {
remainingCustomersCount <- execute(query).map(identity[UUID](_)).runCount
} yield (allCustomersCount, remainingCustomersCount))

assertZIO(result)(equalTo((5L, 4L))).mapErrorCause(cause => Cause.stackless(cause.untraced))
assertZIO(result)(equalTo((6L, 4L))).mapErrorCause(cause => Cause.stackless(cause.untraced))
}
) @@ sequential
}

0 comments on commit d83b2e0

Please sign in to comment.