forked from LaconicNetwork/kompose
Add tests for unsupported keys in k8s transformer
This commit is contained in:
parent
d5d0a3f03a
commit
af9c6585ee
@ -18,6 +18,8 @@ package kubernetes
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
deployapi "github.com/openshift/origin/pkg/deploy/api"
|
deployapi "github.com/openshift/origin/pkg/deploy/api"
|
||||||
@ -353,3 +355,36 @@ func TestConvertRestartOptions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestUnsupportedKeys test checkUnsupportedKey function
|
||||||
|
func TestUnsupportedKeys(t *testing.T) {
|
||||||
|
|
||||||
|
kobjectWithBuild := newKomposeObject()
|
||||||
|
kobjectWithBuild.LoadedFrom = "compose"
|
||||||
|
serviceConfig := kobjectWithBuild.ServiceConfigs["app"]
|
||||||
|
serviceConfig.Build = "./asdf"
|
||||||
|
serviceConfig.Network = []string{}
|
||||||
|
kobjectWithBuild.ServiceConfigs = map[string]kobject.ServiceConfig{"app": serviceConfig}
|
||||||
|
|
||||||
|
// define all test cases for checkUnsupportedKey function
|
||||||
|
testCases := map[string]struct {
|
||||||
|
bundleFile kobject.KomposeObject
|
||||||
|
expectedUnsupportedKeys []string
|
||||||
|
}{
|
||||||
|
"Full Bundle": {
|
||||||
|
kobjectWithBuild,
|
||||||
|
[]string{"build"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
k := Kubernetes{}
|
||||||
|
|
||||||
|
for name, test := range testCases {
|
||||||
|
t.Log("Test case:", name)
|
||||||
|
keys := k.CheckUnsupportedKey(&test.bundleFile, unsupportedKey)
|
||||||
|
if !reflect.DeepEqual(keys, test.expectedUnsupportedKeys) {
|
||||||
|
t.Errorf("ERROR: Expecting unsupported keys: ['%s']. Got: ['%s']", strings.Join(test.expectedUnsupportedKeys, "', '"), strings.Join(keys, "', '"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user