Skip to content

Commit

Permalink
New add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian committed May 15, 2019
1 parent eff674c commit c06bbe6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/add/add_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package add

import (
"strings"
"testing"
"gotest.tools/assert"
)

func TestAdd(t *testing.T) {
addCmd := NewAddCmd()
subcommands := addCmd.Commands()

expectedSubcommandNames := []string{"deployment", "image", "port", "provider", "selector", "sync"}
for _, subcommand := range subcommands {
subCommandName := subcommand.Name()
index := pos(expectedSubcommandNames, subCommandName)
assert.Equal(t, true, index > -1, "Wrong subcommand " + subCommandName)
expectedSubcommandNames = append(expectedSubcommandNames[:index], expectedSubcommandNames[index+1:]...)
}
assert.Equal(t, 0, len(expectedSubcommandNames), "Some subcommands of add are missing: " + strings.Join(expectedSubcommandNames, ", "))
}

func pos(slice []string, value string) int {
for p, v := range slice {
if (v == value) {
return p
}
}
return -1
}

0 comments on commit c06bbe6

Please sign in to comment.