Skip to content

Commit

Permalink
Add test for Kubernetes transformer unsupported keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kadel committed Dec 12, 2016
1 parent fcb8352 commit e1d88f7
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/transformer/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package kubernetes

import (
"fmt"
"reflect"
"strings"
"testing"

deployapi "github.com/openshift/origin/pkg/deploy/api"
Expand Down Expand Up @@ -319,3 +321,36 @@ func TestKomposeConvert(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, "', '"))
}
}

}

0 comments on commit e1d88f7

Please sign in to comment.