Add test to check if subcommands are sorted

Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
This commit is contained in:
Ankush Agarwal 2015-08-06 10:06:42 -07:00
parent b9094633f3
commit 4d212f7853
3 changed files with 14 additions and 5 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"fmt"
"os"
"sort"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api/client"
@ -36,9 +35,6 @@ func main() {
help := "\nCommands:\n"
// TODO(tiborvass): no need to sort if we ensure dockerCommands is sorted
sort.Sort(byName(dockerCommands))
for _, cmd := range dockerCommands {
help += fmt.Sprintf(" %-10.10s%s\n", cmd.name, cmd.description)
}

View File

@ -40,8 +40,8 @@ var dockerCommands = []command{
{"login", "Register or log in to a Docker registry"},
{"logout", "Log out from a Docker registry"},
{"logs", "Fetch the logs of a container"},
{"port", "List port mappings or a specific mapping for the CONTAINER"},
{"pause", "Pause all processes within a container"},
{"port", "List port mappings or a specific mapping for the CONTAINER"},
{"ps", "List containers"},
{"pull", "Pull an image or a repository from a registry"},
{"push", "Push an image or a repository to a registry"},

13
docker/flags_test.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"sort"
"testing"
)
// Tests if the subcommands of docker are sorted
func TestDockerSubcommandsAreSorted(t *testing.T) {
if !sort.IsSorted(byName(dockerCommands)) {
t.Fatal("Docker subcommands are not in sorted order")
}
}