Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -27,12 +27,14 @@ import (
func TestSecretGenerate(t *testing.T) {
tests := []struct {
name string
setup func(t *testing.T, params map[string]interface{}) func()
params map[string]interface{}
expected *v1.Secret
expectErr bool
}{
{
name: "test1",
params: map[string]interface{}{
"name": "foo",
},
@@ -47,6 +49,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test2",
params: map[string]interface{}{
"name": "foo",
"append-hash": true,
@@ -62,6 +65,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test3",
params: map[string]interface{}{
"name": "foo",
"type": "my-type",
@@ -78,6 +82,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test4",
params: map[string]interface{}{
"name": "foo",
"type": "my-type",
@@ -95,6 +100,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test5",
params: map[string]interface{}{
"name": "foo",
"from-literal": []string{"key1=value1", "key2=value2"},
@@ -113,6 +119,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test6",
params: map[string]interface{}{
"name": "foo",
"from-literal": []string{"key1=value1", "key2=value2"},
@@ -132,6 +139,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test7",
params: map[string]interface{}{
"name": "foo",
"from-literal": []string{"key1value1"},
@@ -139,6 +147,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: true,
},
{
name: "test8",
params: map[string]interface{}{
"name": "foo",
"from-file": []string{"key1=/file=2"},
@@ -146,6 +155,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: true,
},
{
name: "test9",
params: map[string]interface{}{
"name": "foo",
"from-file": []string{"key1==value"},
@@ -153,6 +163,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: true,
},
{
name: "test10",
params: map[string]interface{}{
"name": "foo",
"from-literal": []string{"key1==value1"},
@@ -170,6 +181,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test11",
params: map[string]interface{}{
"name": "foo",
"from-literal": []string{"key1==value1"},
@@ -188,6 +200,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test12",
setup: setupEnvFile("key1=value1", "#", "", "key2=value2"),
params: map[string]interface{}{
"name": "valid_env",
@@ -207,6 +220,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test13",
setup: setupEnvFile("key1=value1", "#", "", "key2=value2"),
params: map[string]interface{}{
"name": "valid_env",
@@ -227,6 +241,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test14",
setup: func() func(t *testing.T, params map[string]interface{}) func() {
os.Setenv("g_key1", "1")
os.Setenv("g_key2", "2")
@@ -250,6 +265,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test15",
setup: func() func(t *testing.T, params map[string]interface{}) func() {
os.Setenv("g_key1", "1")
os.Setenv("g_key2", "2")
@@ -274,6 +290,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test16",
params: map[string]interface{}{
"name": "too_many_args",
"from-literal": []string{"key1=value1"},
@@ -282,6 +299,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: true,
},
{
name: "test17",
setup: setupEnvFile("key#1=value1"),
params: map[string]interface{}{
"name": "invalid_key",
@@ -290,6 +308,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: true,
},
{
name: "test18",
setup: setupEnvFile(" key1= value1"),
params: map[string]interface{}{
"name": "with_spaces",
@@ -308,6 +327,7 @@ func TestSecretGenerate(t *testing.T) {
expectErr: false,
},
{
name: "test19",
setup: setupEnvFile(" key1= value1"),
params: map[string]interface{}{
"name": "with_spaces",
@@ -328,22 +348,24 @@ func TestSecretGenerate(t *testing.T) {
},
}
generator := SecretGeneratorV1{}
for i, test := range tests {
if test.setup != nil {
if teardown := test.setup(t, test.params); teardown != nil {
defer teardown()
for i, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.setup != nil {
if teardown := tt.setup(t, tt.params); teardown != nil {
defer teardown()
}
}
}
obj, err := generator.Generate(test.params)
if !test.expectErr && err != nil {
t.Errorf("case %d, unexpected error: %v", i, err)
continue
}
if test.expectErr && err != nil {
continue
}
if !reflect.DeepEqual(obj.(*v1.Secret), test.expected) {
t.Errorf("\ncase %d, expected:\n%#v\nsaw:\n%#v", i, test.expected, obj.(*v1.Secret))
}
obj, err := generator.Generate(tt.params)
if !tt.expectErr && err != nil {
t.Errorf("case %d, unexpected error: %v", i, err)
return
}
if tt.expectErr && err != nil {
return
}
if !reflect.DeepEqual(obj.(*v1.Secret), tt.expected) {
t.Errorf("\ncase %d, expected:\n%#v\nsaw:\n%#v", i, tt.expected, obj.(*v1.Secret))
}
})
}
}