From 06482e5fce1fc75f4971dc24d257a2df1acb8311 Mon Sep 17 00:00:00 2001 From: Robert Ignat Date: Mon, 18 Feb 2019 17:51:39 +0200 Subject: [PATCH] Add ApplyEnvVars test to observations config License: MIT Signed-off-by: Robert Ignat --- observations/config_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 observations/config_test.go diff --git a/observations/config_test.go b/observations/config_test.go new file mode 100644 index 00000000..2dd3b5eb --- /dev/null +++ b/observations/config_test.go @@ -0,0 +1,26 @@ +package observations + +import ( + "os" + "testing" +) + +func TestApplyEnvVars(t *testing.T) { + os.Setenv("CLUSTER_METRICS_ENABLESTATS", "true") + mcfg := &MetricsConfig{} + mcfg.Default() + mcfg.ApplyEnvVars() + + if !mcfg.EnableStats { + t.Fatal("failed to override enable_stats with env var") + } + + os.Setenv("CLUSTER_TRACING_ENABLETRACING", "true") + tcfg := &TracingConfig{} + tcfg.Default() + tcfg.ApplyEnvVars() + + if !tcfg.EnableTracing { + t.Fatal("failed to override enable_tracing with env var") + } +}