forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller_test.go
38 lines (35 loc) · 937 Bytes
/
controller_test.go
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
package config
import (
"testing"
"github.com/stretchr/testify/assert"
apiv1 "k8s.io/api/core/v1"
)
func Test_parseConfigMap(t *testing.T) {
t.Run("Empty", func(t *testing.T) {
c := &Config{}
err := parseConfigMap(&apiv1.ConfigMap{}, c)
assert.NoError(t, err)
})
t.Run("Complex", func(t *testing.T) {
c := &Config{}
err := parseConfigMap(&apiv1.ConfigMap{Data: map[string]string{"artifactRepository": ` archiveLogs: true
s3:
bucket: my-bucket
endpoint: minio:9000
insecure: true
accessKeySecret:
name: my-minio-cred
key: accesskey
secretKeySecret:
name: my-minio-cred
key: secretkey`}}, c)
if assert.NoError(t, err) {
assert.NotEmpty(t, c.ArtifactRepository)
}
})
t.Run("Garbage", func(t *testing.T) {
c := &Config{}
err := parseConfigMap(&apiv1.ConfigMap{Data: map[string]string{"garbage": "garbage"}}, c)
assert.Error(t, err)
})
}