...
1 package eagateway
2
3 import (
4 "flag"
5 "testing"
6
7 "github.com/peterbourgon/ff/v3"
8 "github.com/stretchr/testify/assert"
9 )
10
11 func TestBindConfigFlagsAuthService(t *testing.T) {
12 EnvUserServiceHost := "EA_AUTH_SERVICE_HOST"
13
14 tests := map[string]struct {
15 val string
16 expected string
17 }{
18 "Set AuthService Env": {
19 val: "test",
20 expected: "test",
21 },
22 "Unset AuthServiceEnv Env": {
23 val: "",
24 expected: defaultAuthServiceHost,
25 },
26 }
27
28 for name, tc := range tests {
29 t.Run(name, func(t *testing.T) {
30 t.Setenv(EnvUserServiceHost, tc.val)
31 config := Config{}
32 flags := flag.NewFlagSet("test", flag.ExitOnError)
33 config.BindFlags(flags)
34 err := ff.Parse(flags, []string{}, ff.WithEnvVarNoPrefix(), ff.WithIgnoreUndefined(true))
35 assert.NoError(t, err)
36 assert.Equal(t, tc.expected, config.AuthServiceHost)
37 })
38 }
39 }
40
View as plain text