Skip to content

Commit

Permalink
Testing old/new sink config styles
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix committed Oct 27, 2023
1 parent 16fcd00 commit 96ea661
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 31 deletions.
36 changes: 36 additions & 0 deletions http4s/src/test/resources/test-config-new-style.hocon
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
collector {
interface = "0.0.0.0"
port = 8080

streams {
good {
name = "good"

foo = "hello"
bar = "world"

buffer {
byteLimit = 3145728
recordLimit = 500
timeLimit = 5000
}
}

bad {
name = "bad"

foo = "hello"
bar = "world"

buffer {
byteLimit = 3145728
recordLimit = 500
timeLimit = 5000
}
}
}

ssl {
enable = true
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,51 @@ import io.circe.generic.semiauto._
class ConfigParserSpec extends Specification with CatsEffect {

"Loading the configuration" should {
"use reference.conf and the hocon specified in the path" in {
case class SinkConfig(foo: String, bar: String)
implicit val decoder = deriveDecoder[SinkConfig]
"use reference.conf and the hocon specified in the path" >> {
"for new-style config" in {
assert(resource = "/test-config-new-style.hocon")
}
"for old-style config" in {
assert(resource = "/test-config-old-style.hocon")
}
}
}

val path = Paths.get(getClass.getResource(("/test-config.hocon")).toURI())
private def assert(resource: String) = {
case class SinkConfig(foo: String, bar: String)
implicit val decoder = deriveDecoder[SinkConfig]

val expectedStreams = Config.Streams[SinkConfig](
good = Config.Sink(
name = "good",
buffer = Buffer(
3145728,
500,
5000
),
SinkConfig("hello", "world")
val path = Paths.get(getClass.getResource(resource).toURI)

val expectedStreams = Config.Streams[SinkConfig](
good = Config.Sink(
name = "good",
buffer = Buffer(
3145728,
500,
5000
),
bad = Config.Sink(
name = "bad",
buffer = Buffer(
3145728,
500,
5000
),
SinkConfig("hello", "world")
SinkConfig("hello", "world")
),
bad = Config.Sink(
name = "bad",
buffer = Buffer(
3145728,
500,
5000
),
TestUtils.testConfig.streams.useIpAddressAsPartitionKey
SinkConfig("hello", "world")
),
TestUtils.testConfig.streams.useIpAddressAsPartitionKey
)
val expected = TestUtils
.testConfig
.copy[SinkConfig](
paths = Map.empty[String, String],
streams = expectedStreams,
ssl = TestUtils.testConfig.ssl.copy(enable = true)
)
val expected = TestUtils
.testConfig
.copy[SinkConfig](
paths = Map.empty[String, String],
streams = expectedStreams,
ssl = TestUtils.testConfig.ssl.copy(enable = true)
)

ConfigParser.fromPath[IO, SinkConfig](Some(path)).value.map(_ should beRight(expected))
}
ConfigParser.fromPath[IO, SinkConfig](Some(path)).value.map(_ should beRight(expected))
}
}

0 comments on commit 96ea661

Please sign in to comment.