Merge pull request #15371 from ankushagarwal/flags

Add test to check if subcommands are sorted
This commit is contained in:
Doug Davis 2015-08-07 12:21:00 -04:00
Родитель 27fd64c67f 4d212f7853
Коммит 38e5764132
3 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -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)
}

Просмотреть файл

@ -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
Просмотреть файл

@ -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")
}
}