-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathenv_test.go
More file actions
70 lines (65 loc) · 2.1 KB
/
Copy pathenv_test.go
File metadata and controls
70 lines (65 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package options
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/utils/ptr"
)
func TestParse(t *testing.T) {
tests := map[string]struct {
envs map[string]string
wantOptions VSOEnvOptions
}{
"empty": {
envs: map[string]string{},
wantOptions: VSOEnvOptions{},
},
"set all": {
envs: map[string]string{
"VSO_OUTPUT_FORMAT": "json",
"VSO_CLIENT_CACHE_SIZE": "100",
"VSO_CLIENT_CACHE_PERSISTENCE_MODEL": "memory",
"VSO_MAX_CONCURRENT_RECONCILES": "10",
"VSO_BACKOFF_INITIAL_INTERVAL": "1s",
"VSO_BACKOFF_MAX_INTERVAL": "60s",
"VSO_BACKOFF_MAX_ELAPSED_TIME": "24h",
"VSO_BACKOFF_RANDOMIZATION_FACTOR": "0.5",
"VSO_BACKOFF_MULTIPLIER": "2.5",
"VSO_GLOBAL_TRANSFORMATION_OPTIONS": "gOpt1,gOpt2",
"VSO_GLOBAL_VAULT_AUTH_OPTIONS": "vOpt1,vOpt2",
"VSO_CLIENT_CACHE_NUM_LOCKS": "10",
"VSO_KUBE_CLIENT_QPS": "100",
"VSO_KUBE_CLIENT_BURST": "1000",
},
wantOptions: VSOEnvOptions{
OutputFormat: "json",
ClientCacheSize: ptr.To(100),
ClientCachePersistenceModel: "memory",
MaxConcurrentReconciles: ptr.To(10),
BackoffInitialInterval: time.Second * 1,
BackoffMaxInterval: time.Second * 60,
BackoffMaxElapsedTime: time.Hour * 24,
BackoffRandomizationFactor: 0.5,
BackoffMultiplier: 2.5,
GlobalTransformationOptions: []string{"gOpt1", "gOpt2"},
GlobalVaultAuthOptions: []string{"vOpt1", "vOpt2"},
ClientCacheNumLocks: ptr.To(10),
KubeClientQPS: 100,
KubeClientBurst: ptr.To(uint(1000)),
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
for env, val := range tt.envs {
t.Setenv(env, val)
}
gotOptions := VSOEnvOptions{}
require.NoError(t, gotOptions.Parse())
assert.Equal(t, tt.wantOptions, gotOptions)
})
}
}