update edit add secrets/configmaps to use plugins

This commit is contained in:
Seth Pollack
2019-03-20 09:24:10 -04:00
parent 46bd38e89d
commit b60fca05bd
4 changed files with 66 additions and 96 deletions

View File

@@ -65,45 +65,33 @@ func TestMakeConfigMapArgs(t *testing.T) {
}
func TestMergeFlagsIntoCmArgs_LiteralSources(t *testing.T) {
ds := &types.DataSources{}
kv := []types.KVSource{}
err := mergeFlagsIntoCmArgs(ds, flagsAndArgs{LiteralSources: []string{"k1=v1"}})
if err != nil {
t.Fatalf("Merge initial literal source should not return error")
}
mergeFlagsIntoCmArgs(&kv, flagsAndArgs{LiteralSources: []string{"k1=v1"}})
if len(ds.LiteralSources) != 1 {
if len(kv) != 1 {
t.Fatalf("Initial literal source should have been added")
}
err = mergeFlagsIntoCmArgs(ds, flagsAndArgs{LiteralSources: []string{"k2=v2"}})
if err != nil {
t.Fatalf("Merge second literal source should not return error")
}
mergeFlagsIntoCmArgs(&kv, flagsAndArgs{LiteralSources: []string{"k2=v2"}})
if len(ds.LiteralSources) != 2 {
if len(kv) != 2 {
t.Fatalf("Second literal source should have been added")
}
}
func TestMergeFlagsIntoCmArgs_FileSources(t *testing.T) {
ds := &types.DataSources{}
kv := []types.KVSource{}
err := mergeFlagsIntoCmArgs(ds, flagsAndArgs{FileSources: []string{"file1"}})
if err != nil {
t.Fatalf("Merge initial file source should not return error")
}
mergeFlagsIntoCmArgs(&kv, flagsAndArgs{FileSources: []string{"file1"}})
if len(ds.FileSources) != 1 {
if len(kv) != 1 {
t.Fatalf("Initial file source should have been added")
}
err = mergeFlagsIntoCmArgs(ds, flagsAndArgs{FileSources: []string{"file2"}})
if err != nil {
t.Fatalf("Merge second file source should not return error")
}
mergeFlagsIntoCmArgs(&kv, flagsAndArgs{FileSources: []string{"file2"}})
if len(ds.FileSources) != 2 {
if len(kv) != 2 {
t.Fatalf("Second file source should have been added")
}
}
@@ -111,19 +99,16 @@ func TestMergeFlagsIntoCmArgs_FileSources(t *testing.T) {
func TestMergeFlagsIntoCmArgs_EnvSource(t *testing.T) {
envFileName := "env1"
envFileName2 := "env2"
ds := &types.DataSources{}
kv := []types.KVSource{}
err := mergeFlagsIntoCmArgs(ds, flagsAndArgs{EnvFileSource: envFileName})
if err != nil {
t.Fatalf("Merge initial env source should not return error")
mergeFlagsIntoCmArgs(&kv, flagsAndArgs{EnvFileSource: envFileName})
if len(kv) != 1 {
t.Fatalf("Initial env source should have been added")
}
if ds.EnvSource != envFileName {
t.Fatalf("Initial env source filename should have been added")
}
err = mergeFlagsIntoCmArgs(ds, flagsAndArgs{EnvFileSource: envFileName2})
if err == nil {
t.Fatalf("Updating env source should return an error")
mergeFlagsIntoCmArgs(&kv, flagsAndArgs{EnvFileSource: envFileName2})
if len(kv) != 2 {
t.Fatalf("Second env source should have been added")
}
}