aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-08-15 00:33:06 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-08-15 00:33:06 +0200
commita90d4aa75e7fdf12a85177f4e81463439bfe5bb3 (patch)
tree2b815c06862332752ff4192c4bdceb4413cf2945 /kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala
parent86c72d622ac027dc96f9a744771c0a468d46dc60 (diff)
downloadKamon-a90d4aa75e7fdf12a85177f4e81463439bfe5bb3.tar.gz
Kamon-a90d4aa75e7fdf12a85177f4e81463439bfe5bb3.tar.bz2
Kamon-a90d4aa75e7fdf12a85177f4e81463439bfe5bb3.zip
separate the build into core, testkit and core-tests projects
Diffstat (limited to 'kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala')
-rw-r--r--kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala48
1 files changed, 48 insertions, 0 deletions
diff --git a/kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala b/kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala
new file mode 100644
index 00000000..2dee46ab
--- /dev/null
+++ b/kamon-core-tests/src/test/scala/kamon/EnvironmentSpec.scala
@@ -0,0 +1,48 @@
+package kamon
+
+import com.typesafe.config.ConfigFactory
+import org.scalatest.{Matchers, WordSpec}
+
+class EnvironmentSpec extends WordSpec with Matchers {
+ private val baseConfig = ConfigFactory.parseString(
+ """
+ |kamon.environment {
+ | service = environment-spec
+ | host = auto
+ | instance = auto
+ |}
+ """.stripMargin
+ )
+
+ "the Kamon environment" should {
+ "assign a host and instance name when they are set to 'auto'" in {
+ val env = Environment.fromConfig(baseConfig)
+
+ env.host shouldNot be("auto")
+ env.instance shouldNot be("auto")
+ env.instance shouldBe s"environment-spec@${env.host}"
+ }
+
+ "use the configured host and instance, if provided" in {
+ val customConfig = ConfigFactory.parseString(
+ """
+ |kamon.environment {
+ | host = spec-host
+ | instance = spec-instance
+ |}
+ """.stripMargin)
+
+ val env = Environment.fromConfig(customConfig.withFallback(baseConfig))
+
+ env.host should be("spec-host")
+ env.instance should be("spec-instance")
+ }
+
+ "always return the same incarnation name" in {
+ val envOne = Environment.fromConfig(baseConfig)
+ val envTwo = Environment.fromConfig(baseConfig)
+
+ envOne.incarnation shouldBe envTwo.incarnation
+ }
+ }
+}