Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config loading #334

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion http4s/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
collector {
{
paths {}

p3p {
Expand Down
18 changes: 18 additions & 0 deletions http4s/src/test/resources/test-config.hocon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
collector {
interface = "0.0.0.0"
port = 8080

streams {
good = "good"
bad = "bad"

sink {
foo = "hello"
bar = "world"
}
}

ssl {
enable = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.snowplowanalytics.snowplow.collector.core

import java.nio.file.Paths

import org.specs2.mutable.Specification

import cats.effect.IO

import cats.effect.testing.specs2.CatsEffect

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]

val path = Paths.get(getClass.getResource(("/test-config.hocon")).toURI())

val expectedStreams = Config.Streams[SinkConfig](
"good",
"bad",
TestUtils.testConfig.streams.useIpAddressAsPartitionKey,
SinkConfig("hello", "world"),
TestUtils.testConfig.streams.buffer
)
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))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ object TestUtils {
),
enableDefaultRedirect = false,
redirectDomains = Set.empty[String],
preTerminationPeriod = 5.minutes
preTerminationPeriod = 10.seconds
)
}
Loading