mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 16:56:47 +00:00
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:
parent
d8a5952cfe
commit
4c12c2e2f8
@ -341,3 +341,37 @@ func TestRead_AuthProxy_DefaultsOverrides(t *testing.T) {
|
|||||||
t.Fail()
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user