Skip to content
Permalink
Browse files

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>
  • Loading branch information...
LucasRoesler authored and alexellis committed Jun 28, 2019
1 parent d8a5952 commit 4c12c2e2f8f3f4b4bfd740afee628d8b5524230c
Showing with 34 additions and 0 deletions.
  1. +34 −0 gateway/types/readconfig_test.go
@@ -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)
}
})
}

0 comments on commit 4c12c2e

Please sign in to comment.
You can’t perform that action at this time.