ship: v0.1 Foundation milestone complete (#1)
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVersionCommandExists(t *testing.T) {
|
||||
found := false
|
||||
for _, cmd := range rootCmd.Commands() {
|
||||
if cmd.Name() == "version" {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("version command not registered")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRootHasAllSubcommands(t *testing.T) {
|
||||
expected := []string{"version", "init", "status", "node", "job"}
|
||||
registered := make(map[string]bool)
|
||||
for _, cmd := range rootCmd.Commands() {
|
||||
registered[cmd.Name()] = true
|
||||
}
|
||||
for _, name := range expected {
|
||||
if !registered[name] {
|
||||
t.Errorf("expected subcommand %q not registered", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeSubcommands(t *testing.T) {
|
||||
expected := []string{"join", "leave", "list"}
|
||||
registered := make(map[string]bool)
|
||||
for _, cmd := range nodeCmd.Commands() {
|
||||
registered[cmd.Name()] = true
|
||||
}
|
||||
for _, name := range expected {
|
||||
if !registered[name] {
|
||||
t.Errorf("expected node subcommand %q not registered", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestJobSubcommands(t *testing.T) {
|
||||
expected := []string{"run", "list", "stop", "logs"}
|
||||
registered := make(map[string]bool)
|
||||
for _, cmd := range jobCmd.Commands() {
|
||||
registered[cmd.Name()] = true
|
||||
}
|
||||
for _, name := range expected {
|
||||
if !registered[name] {
|
||||
t.Errorf("expected job subcommand %q not registered", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRootHelpMentionsKeyPillars(t *testing.T) {
|
||||
help := rootCmd.Long
|
||||
for _, pillar := range []string{"offline", "CLI", "Nomad", "simplicity"} {
|
||||
if !strings.Contains(strings.ToLower(help), strings.ToLower(pillar)) {
|
||||
t.Errorf("root help does not mention pillar %q", pillar)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user