Add tests for loading the logs provider value from the env

**What**
- Ensure that we are loading the log provider url correctly, including
fallback to the function provider, when the value is set

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
This commit is contained in:
Lucas Roesler 2019-06-28 19:57:38 +02:00 committed by Alex Ellis
parent d8a5952cfe
commit 4c12c2e2f8

View File

@ -341,3 +341,37 @@ func TestRead_AuthProxy_DefaultsOverrides(t *testing.T) {
t.Fail()
}
}
func TestRead_LogsProviderURL(t *testing.T) {
defaults := NewEnvBucket()
t.Run("default value is nil when functions_provider_url is empty", func(t *testing.T) {
readConfig := ReadConfig{}
config := readConfig.Read(defaults)
if config.LogsProviderURL != nil {
t.Fatalf("config.LogsProviderURL, want: %s, got: %s\n", "", config.LogsProviderURL)
}
})
t.Run("default value is equal to functions_provider_url", func(t *testing.T) {
expected := "functions.example.com"
defaults.Setenv("functions_provider_url", expected)
readConfig := ReadConfig{}
config := readConfig.Read(defaults)
if config.LogsProviderURL.String() != expected {
t.Fatalf("config.LogsProviderURL, want: %s, got: %s\n", expected, config.LogsProviderURL)
}
})
t.Run("override by logs_provider_url", func(t *testing.T) {
expected := "logs.example.com"
defaults.Setenv("logs_provider_url", expected)
readConfig := ReadConfig{}
config := readConfig.Read(defaults)
if config.LogsProviderURL.String() != expected {
t.Fatalf("config.LogsProviderURL, want: %s, got: %s\n", expected, config.LogsProviderURL)
}
})
}