Skip to content

Commit a0c22c3

Browse files
committed
Add tests for cache invalidation with ref config and full config
1 parent 49770d9 commit a0c22c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

config/src/test/scala/com/typesafe/config/impl/PublicApiTest.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,28 @@ class PublicApiTest extends TestUtils {
937937
assertTrue("stuff gets cached repeatedly conf", conf3 eq conf4)
938938
}
939939

940+
@Test
941+
def invalidateReferenceConfig(): Unit = {
942+
val orig = ConfigFactory.defaultReference()
943+
val cached = ConfigFactory.defaultReference()
944+
assertTrue("reference config was cached", orig eq cached)
945+
946+
ConfigFactory.invalidateCaches()
947+
val changed = ConfigFactory.defaultReference()
948+
assertTrue("reference config was invalidated", orig ne changed)
949+
}
950+
951+
@Test
952+
def invalidateFullConfig(): Unit = {
953+
val orig = ConfigFactory.load()
954+
val cached = ConfigFactory.load()
955+
assertTrue("full config was cached", orig eq cached)
956+
957+
ConfigFactory.invalidateCaches()
958+
val changed = ConfigFactory.load()
959+
assertTrue("full config was invalidated", orig ne changed)
960+
}
961+
940962
@Test
941963
def canUseSomeValuesWithoutResolving(): Unit = {
942964
val conf = ConfigFactory.parseString("a=42,b=${NOPE}")

0 commit comments

Comments
 (0)