@@ -23,7 +23,7 @@ import munit.CatsEffectSuite
23
23
class HoconSpec extends CatsEffectSuite {
24
24
import lt .dvim .ciris .Hocon ._
25
25
26
- private val config = ConfigFactory .parseString("""
26
+ private val config = ConfigFactory .parseString(s """
27
27
|nested {
28
28
| config {
29
29
| int = 2
@@ -33,30 +33,34 @@ class HoconSpec extends CatsEffectSuite {
33
33
| per = 2 weeks
34
34
| }
35
35
|}
36
+ |subst {
37
+ | int = $$ {nested.config.int}
38
+ |}
36
39
""" .stripMargin)
37
40
38
- private val hocon = hoconAt(config)(" nested.config" )
41
+ private val nested = hoconAt(config)(" nested.config" )
42
+ private val subst = hoconAt(config)(" subst" )
39
43
40
44
test(" parse Int" ) {
41
- hocon (" int" ).as[Int ].load[IO ] assertEquals 2
45
+ nested (" int" ).as[Int ].load[IO ] assertEquals 2
42
46
}
43
47
test(" parse String" ) {
44
- hocon (" str" ).as[String ].load[IO ] assertEquals " labas"
48
+ nested (" str" ).as[String ].load[IO ] assertEquals " labas"
45
49
}
46
50
test(" parse java Duration" ) {
47
- hocon (" dur" ).as[java.time.Duration ].load[IO ] assertEquals java.time.Duration .ofMillis(10 )
51
+ nested (" dur" ).as[java.time.Duration ].load[IO ] assertEquals java.time.Duration .ofMillis(10 )
48
52
}
49
53
test(" parse scala Duration" ) {
50
- hocon (" dur" ).as[FiniteDuration ].load[IO ] assertEquals 10 .millis
54
+ nested (" dur" ).as[FiniteDuration ].load[IO ] assertEquals 10 .millis
51
55
}
52
56
test(" parse Boolean" ) {
53
- hocon (" bool" ).as[Boolean ].load[IO ] assertEquals true
57
+ nested (" bool" ).as[Boolean ].load[IO ] assertEquals true
54
58
}
55
59
test(" parse Period" ) {
56
- hocon (" per" ).as[java.time.Period ].load[IO ] assertEquals java.time.Period .ofWeeks(2 )
60
+ nested (" per" ).as[java.time.Period ].load[IO ] assertEquals java.time.Period .ofWeeks(2 )
57
61
}
58
62
test(" handle missing" ) {
59
- hocon (" missing" )
63
+ nested (" missing" )
60
64
.as[Int ]
61
65
.attempt[IO ]
62
66
.map {
@@ -66,7 +70,7 @@ class HoconSpec extends CatsEffectSuite {
66
70
.assertEquals(" Missing nested.config.missing" )
67
71
}
68
72
test(" handle decode error" ) {
69
- hocon (" str" )
73
+ nested (" str" )
70
74
.as[Int ]
71
75
.attempt[IO ]
72
76
.map {
@@ -75,4 +79,7 @@ class HoconSpec extends CatsEffectSuite {
75
79
}
76
80
.assertEquals(" Nested.config.str with value labas cannot be converted to Int" )
77
81
}
82
+ test(" resolve substitutions" ) {
83
+ subst(" int" ).as[Int ].load[IO ] assertEquals 2
84
+ }
78
85
}
0 commit comments