forked from LaconicNetwork/kompose
Failing when port is specified with labels
Resolves #522 Kompose will give FATAL error if labels are given but ports are not defined
This commit is contained in:
@@ -323,3 +323,27 @@ func TestNormalizeServiceNames(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckLabelsPorts(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
noOfPort int
|
||||
labels string
|
||||
svcName string
|
||||
expectError bool
|
||||
}{
|
||||
{"ports is defined", 1, "NodePort", "foo", false},
|
||||
{"ports is not defined", 0, "NodePort", "foo", true},
|
||||
}
|
||||
|
||||
var err error
|
||||
for _, testcase := range testCases {
|
||||
t.Log(testcase.name)
|
||||
err = checkLabelsPorts(testcase.noOfPort, testcase.labels, testcase.svcName)
|
||||
if testcase.expectError && err == nil {
|
||||
t.Log("Expected error, got ", err)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user