-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathplugin_test.go
89 lines (78 loc) · 2.01 KB
/
plugin_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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/target/impeller/types"
"github.com/target/impeller/utils"
"github.com/target/impeller/utils/report"
)
func TestOverridesValueFiles(t *testing.T) {
p := &Plugin{
ValueFiles: []string{"test", "file"},
}
release := &types.Release{}
overrides := p.overrides(release)
require.Len(t, overrides, 2)
assert.Equal(t, "test", overrides[0].Value)
assert.False(t, overrides[0].ValueSecret)
assert.Equal(t, "file", overrides[1].Value)
assert.False(t, overrides[1].ValueSecret)
}
func TestOverridesIndividualOverrides(t *testing.T) {
override := "test"
p := &Plugin{}
release := &types.Release{
Overrides: []types.Override{
types.Override{
Target: "image.tag",
Value: types.Value{
Value: &override,
},
},
},
}
overrides := p.overrides(release)
require.Len(t, overrides, 1)
assert.Equal(t, "set", overrides[0].Name)
assert.Equal(t, "image.tag=test", overrides[0].Value)
assert.True(t, overrides[0].ValueSecret)
}
func TestOverridesIndividualOverridesPrint(t *testing.T) {
override := "test"
p := &Plugin{}
release := &types.Release{
Overrides: []types.Override{
types.Override{
Target: "image.tag",
Value: types.Value{
Value: &override,
ShowValue: true,
},
},
},
}
overrides := p.overrides(release)
require.Len(t, overrides, 1)
assert.Equal(t, "set", overrides[0].Name)
assert.Equal(t, "image.tag=test", overrides[0].Value)
assert.False(t, overrides[0].ValueSecret)
}
func TestPlugin_ExecReport(t *testing.T) {
p := Plugin{
ClusterConfigPath: "./test-clusters",
ClustersList: report.Clusters{},
ValueFiles: nil,
KubeConfig: "",
KubeContext: "",
Dryrun: false,
Diffrun: false,
Audit: true,
AuditFile: "./go-test.csv",
}
clist, err := utils.ListClusters(p.ClusterConfigPath)
require.Nil(t, err)
p.ClustersList = clist
err = p.Exec()
require.Nil(t, err)
}