Skip to content

Commit

Permalink
Moved tests according to changes introduced by #39
Browse files Browse the repository at this point in the history
  • Loading branch information
vil1 committed Feb 10, 2019
1 parent de4d1be commit 8c24080
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 63 deletions.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ lazy val scalacheck = project
)
.dependsOn(core)


lazy val playJson = project
.in(file("modules/play-json"))
.settings(
Expand All @@ -58,7 +57,6 @@ lazy val playJson = project
)
.dependsOn(core)


lazy val tests = project
.in(file("modules/tests"))
.settings(
Expand Down
27 changes: 0 additions & 27 deletions modules/play-json/src/test/scala/Main.scala

This file was deleted.

3 changes: 2 additions & 1 deletion modules/tests/src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object Main {
("Examples", SchemaModuleExamples.tests(harness)),
("JSON", JsonExamples.tests(harness)),
("Scalacheck generators", GenModuleExamples.tests(harness)),
("Generic Show interpreter", ShowExamples.tests(harness))
("Generic Show interpreter", ShowExamples.tests(harness)),
("Play-JSON codecs", PlayJsonExamples.tests(harness))
)

def main(args: Array[String]): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package scalaz

package schema

package play.json
package tests

import testz._
import _root_.play.api.libs.json._
import monocle.Iso
import org.scalacheck._, Prop._, Arbitrary._

object PlayJsonExamples {

val jsonModule = new PlayJsonModule[JsonSchema.type] with scalacheck.GenModule[JsonSchema.type] {
val R = JsonSchema
val module = new TestModule with play.json.PlayJsonModule[JsonSchema.type]
with scalacheck.GenModule[JsonSchema.type] {

implicit val primToGenNT = new (JsonSchema.Prim ~> Gen) {
override def apply[A](prim: JsonSchema.Prim[A]): Gen[A] = prim match {
Expand Down Expand Up @@ -52,7 +51,7 @@ object PlayJsonExamples {
def tests[T](harness: Harness[T]): T = {
import harness._
import Schema._
import jsonModule._
import module._
import JsonSchema._

section("play-json codecs")(
Expand All @@ -67,34 +66,6 @@ object PlayJsonExamples {
)
},
test("Derived `Reads` and `Writes` for a given schema should be symmetrical") { () =>
val user = record(
"active" -*>: prim(JsonSchema.JsonBool),
Iso[Boolean, User](User.apply)(_.active)
)

val admin = record(
"rights" -*>: seq(prim(JsonSchema.JsonString)),
Iso[List[String], Admin](Admin.apply)(_.rights)
)

val person = record(
"name" -*>: prim(JsonSchema.JsonString) :*:
"role" -*>: optional(
union(
"user" -+>: user :+:
"admin" -+>: admin,
Iso[User \/ Admin, Role] {
case -\/(u) => u
case \/-(a) => a
} {
case u @ User(_) => -\/(u)
case a @ Admin(_) => \/-(a)
}
)
),
Iso[(String, Option[Role]), Person]((Person.apply _).tupled)(p => (p.name, p.role))
)

implicit val personGen = Arbitrary(person.to[Gen])

val reader = person.to[Reads]
Expand Down

0 comments on commit 8c24080

Please sign in to comment.