-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #548 from bwiercinski/issue528_effectful_discipline
create DisciplineFSuite #528
- Loading branch information
Showing
5 changed files
with
254 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
modules/discipline/test/src/DisciplineFSuiteIntegrationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package weaver.discipline | ||
|
||
import cats.effect.{ IO, Resource } | ||
|
||
import weaver.{ BaseIOSuite, SimpleIOSuite } | ||
|
||
object DisciplineFSuiteIntegrationTest extends SimpleIOSuite { | ||
|
||
test("Runs tests successfully") { | ||
MetaSuccess.spec(Nil).compile.toList.map { outcomes => | ||
expect.all( | ||
outcomes.map(_.name).toSet == Set("Int: rickroll.rolls", | ||
"Int: rickroll.ricks"), | ||
outcomes.map(_.status.isFailed).forall(_ == false) | ||
) | ||
} | ||
} | ||
|
||
test("Reports failures correctly") { | ||
MetaFailure.spec(Nil).compile.toList.map { outcomes => | ||
expect.all( | ||
outcomes.map(_.name).toSet == Set("Boolean: rickroll.rolls", | ||
"Boolean: rickroll.ricks"), | ||
outcomes.map(_.status.isFailed).count(_ == true) == 1, | ||
outcomes.find(_.status.isFailed).exists { to => | ||
to.name == "Boolean: rickroll.ricks" | ||
} | ||
) | ||
} | ||
} | ||
|
||
test("Captures exceptions correctly") { | ||
import RickRoll._ | ||
MetaException.spec(Nil).compile.toList.map { outcomes => | ||
expect.all( | ||
outcomes.forall(_.cause.isDefined), | ||
outcomes.flatMap(_.cause).collect { | ||
case `oops` | `oops2` => true | ||
case _ => false | ||
}.size == 2 | ||
) | ||
} | ||
} | ||
|
||
test("Shared resource fails to start") { | ||
FailingResource.spec(Nil).compile.toList.attempt.map { outcomes => | ||
expect.all( | ||
outcomes.isLeft, | ||
outcomes.left.exists(_ == resourceStart) | ||
) | ||
} | ||
} | ||
|
||
object MetaSuccess extends DisciplineFSuite[IO] with BaseIOSuite { | ||
override type Res = String | ||
override def sharedResource: Resource[IO, String] = | ||
Resource.pure("resource") | ||
|
||
checkAll("Int").pure(_ => RickrollTests[Int].all) | ||
} | ||
|
||
object MetaFailure extends DisciplineFSuite[IO] with BaseIOSuite { | ||
override type Res = String | ||
override def sharedResource: Resource[IO, String] = | ||
Resource.pure("resource") | ||
|
||
checkAll("Boolean").pure(_ => RickrollTests[Boolean].all) | ||
} | ||
|
||
object MetaException extends DisciplineFSuite[IO] with BaseIOSuite { | ||
override type Res = String | ||
override def sharedResource: Resource[IO, String] = | ||
Resource.pure("resource") | ||
|
||
checkAll("String").pure(_ => RickrollTests[String].all) | ||
} | ||
|
||
object resourceStart extends Exception | ||
object FailingResource extends DisciplineFSuite[IO] with BaseIOSuite { | ||
override type Res = String | ||
override def sharedResource: Resource[IO, String] = | ||
Resource.eval(IO.raiseError(resourceStart)) | ||
|
||
checkAll("Int").pure(_ => RickrollTests[Int].all) | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
modules/discipline/test/src/DisciplineIntegrationTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package weaver.discipline | ||
|
||
import weaver.SimpleIOSuite | ||
|
||
object DisciplineIntegrationTest extends SimpleIOSuite { | ||
|
||
test("Runs tests successfully") { | ||
MetaSuccess.spec(Nil).compile.toList.map { outcomes => | ||
expect.all( | ||
outcomes.map(_.name).toSet == Set("Int: rickroll.rolls", | ||
"Int: rickroll.ricks"), | ||
outcomes.map(_.status.isFailed).forall(_ == false) | ||
) | ||
} | ||
} | ||
|
||
test("Reports failures correctly") { | ||
MetaFailure.spec(Nil).compile.toList.map { outcomes => | ||
expect.all( | ||
outcomes.map(_.name).toSet == Set("Boolean: rickroll.rolls", | ||
"Boolean: rickroll.ricks"), | ||
outcomes.map(_.status.isFailed).count(_ == true) == 1, | ||
outcomes.find(_.status.isFailed).exists { to => | ||
to.name == "Boolean: rickroll.ricks" | ||
} | ||
) | ||
} | ||
} | ||
|
||
test("Captures exceptions correctly") { | ||
import RickRoll._ | ||
MetaException.spec(Nil).compile.toList.map { outcomes => | ||
expect.all( | ||
outcomes.forall(_.cause.isDefined), | ||
outcomes.flatMap(_.cause).collect { | ||
case `oops` | `oops2` => true | ||
case _ => false | ||
}.size == 2 | ||
) | ||
} | ||
} | ||
|
||
object MetaSuccess extends weaver.FunSuite with Discipline { | ||
checkAll("Int", RickrollTests[Int].all) | ||
} | ||
|
||
object MetaFailure extends weaver.FunSuite with Discipline { | ||
checkAll("Boolean", RickrollTests[Boolean].all) | ||
} | ||
|
||
object MetaException extends weaver.FunSuite with Discipline { | ||
checkAll("String", RickrollTests[String].all) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters