-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce munit-cats-effect * Use standard MUnit Cats Effect suite / assertions
- Loading branch information
1 parent
0010827
commit 96174df
Showing
111 changed files
with
725 additions
and
996 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
66 changes: 0 additions & 66 deletions
66
...c/test/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/ClasspathResourceLoaderSpec.scala
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
.../test/scala/ch/epfl/bluebrain/nexus/delta/kernel/utils/ClasspathResourceLoaderSuite.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,65 @@ | ||
package ch.epfl.bluebrain.nexus.delta.kernel.utils | ||
|
||
import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceError.{InvalidJson, InvalidJsonObject} | ||
import io.circe.syntax._ | ||
import io.circe.{Json, JsonObject} | ||
import munit.CatsEffectSuite | ||
|
||
class ClasspathResourceLoaderSuite extends CatsEffectSuite { | ||
private val loader: ClasspathResourceLoader = ClasspathResourceLoader() | ||
|
||
test("return the path") { | ||
loader.absolutePath("resource.txt").assert(_.endsWith("resource.txt")) | ||
} | ||
|
||
test("return the contents of a handlebar template") { | ||
loader | ||
.contentOf("resource.txt", "value" -> "v") | ||
.assertEquals("A text resource with replacement 'v'") | ||
} | ||
|
||
test("return the contents of a handlebar template, multiple times") { | ||
val io = loader.contentOf("resource.txt", "value" -> "v") | ||
|
||
for { | ||
_ <- io.assertEquals("A text resource with replacement 'v'") | ||
_ <- io.assertEquals("A text resource with replacement 'v'") | ||
} yield { | ||
() | ||
} | ||
} | ||
|
||
test("return the contents of a handlebar template as json") { | ||
loader | ||
.jsonContentOf("resource.json", "value" -> "v") | ||
.assertEquals(Json.obj("k" -> "v".asJson)) | ||
} | ||
|
||
test("fail when a file cannot be parsed as json") { | ||
loader | ||
.jsonContentOf("resource.txt", "value" -> "v") | ||
.intercept[InvalidJson] | ||
} | ||
|
||
test("return the contaents of a handlebar template as a json object") { | ||
loader | ||
.jsonObjectContentOf("resource.json", "value" -> "v") | ||
.assertEquals(JsonObject("k" -> "v".asJson)) | ||
} | ||
|
||
test("fail when a file contains JSON but is not a json object") { | ||
loader | ||
.jsonObjectContentOf("resource-json-array.json") | ||
.intercept[InvalidJsonObject] | ||
.assertEquals( | ||
InvalidJsonObject("resource-json-array.json") | ||
) | ||
} | ||
|
||
test("fail when a resource does not exist") { | ||
loader | ||
.contentOf("resource2.txt", "value" -> "v") | ||
.intercept[Throwable] | ||
.assert(e => e.getMessage.contains("not found") && e.getMessage.contains("resource2.txt")) | ||
} | ||
} |
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
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
Oops, something went wrong.