-
Notifications
You must be signed in to change notification settings - Fork 18
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 #277 from Kazark/munit
Convert all specs from Specs2 to MUnit
- Loading branch information
Showing
7 changed files
with
437 additions
and
465 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,9 @@ tags | |
.bloop | ||
.metals | ||
project/metals.sbt | ||
.bsp/ | ||
.bsp/ | ||
|
||
# gtags | ||
GPATH | ||
GRTAGS | ||
GTAGS |
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
62 changes: 29 additions & 33 deletions
62
modules/caffeine/src/test/scala/io/chrisdavenport/mules/caffeine/CaffeineCacheSpec.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 |
---|---|---|
@@ -1,47 +1,43 @@ | ||
package io.chrisdavenport.mules.caffeine | ||
|
||
import org.specs2.mutable.Specification | ||
import scala.concurrent.duration._ | ||
import cats.effect._ | ||
// import cats.effect.implicits._ | ||
import cats.effect.IO | ||
import cats.effect.testing.specs2.CatsIO | ||
import munit._ | ||
import io.chrisdavenport.mules.TimeSpec | ||
|
||
class CaffeineCacheSpec extends Specification with CatsIO { | ||
"CaffeineCache" should { | ||
"get a value in a quicker period than the timeout" in { | ||
val setup = for { | ||
cache <- CaffeineCache.build[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)), None, None) | ||
_ <- cache.insert("Foo", 1) | ||
_ <- Timer[IO].sleep(1.milli) | ||
value <- cache.lookup("Foo") | ||
} yield value | ||
setup.map(_ must_=== Some(1)) | ||
class CaffeineCacheSpec extends CatsEffectSuite { | ||
test("CaffeineCache should get a value in a quicker period than the timeout") { | ||
for { | ||
cache <- CaffeineCache.build[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)), None, None) | ||
_ <- cache.insert("Foo", 1) | ||
_ <- Timer[IO].sleep(1.milli) | ||
value <- cache.lookup("Foo") | ||
} yield { | ||
assertEquals(value, Some(1)) | ||
} | ||
} | ||
|
||
|
||
"remove a value after delete" in { | ||
val setup = for { | ||
cache <- CaffeineCache.build[IO, String, Int](None, None, None) | ||
_ <- cache.insert("Foo", 1) | ||
_ <- cache.delete("Foo") | ||
value <- cache.lookup("Foo") | ||
} yield value | ||
setup.map(_ must_=== None) | ||
test("CaffeineCache should remove a value after delete") { | ||
for { | ||
cache <- CaffeineCache.build[IO, String, Int](None, None, None) | ||
_ <- cache.insert("Foo", 1) | ||
_ <- cache.delete("Foo") | ||
value <- cache.lookup("Foo") | ||
} yield { | ||
assertEquals(value, None) | ||
} | ||
} | ||
|
||
|
||
"Lookup after interval fails to get a value" in { | ||
val setup = for { | ||
cache <- CaffeineCache.build[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)), None, None) | ||
_ <- cache.insert("Foo", 1) | ||
_ <- Timer[IO].sleep(2.second) | ||
value <- cache.lookup("Foo") | ||
} yield value | ||
setup.map(_ must_=== None) | ||
test("CaffeineCache should Lookup after interval fails to get a value") { | ||
for { | ||
cache <- CaffeineCache.build[IO, String, Int](Some(TimeSpec.unsafeFromDuration(1.second)), None, None) | ||
_ <- cache.insert("Foo", 1) | ||
_ <- Timer[IO].sleep(2.second) | ||
value <- cache.lookup("Foo") | ||
} yield { | ||
assertEquals(value, None) | ||
} | ||
|
||
|
||
} | ||
} | ||
} |
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.