Skip to content

Commit

Permalink
Add tests for loading the logs provider value from the env
Browse files Browse the repository at this point in the history
**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 Jul 6, 2019
1 parent d8a5952 commit 4c12c2e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions gateway/types/readconfig_test.go
Expand Up @@ -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.