mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #15371 from ankushagarwal/flags
Add test to check if subcommands are sorted
This commit is contained in:
commit
38e5764132
3 changed files with 14 additions and 5 deletions
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/api/client"
|
"github.com/docker/docker/api/client"
|
||||||
|
@ -36,9 +35,6 @@ func main() {
|
||||||
|
|
||||||
help := "\nCommands:\n"
|
help := "\nCommands:\n"
|
||||||
|
|
||||||
// TODO(tiborvass): no need to sort if we ensure dockerCommands is sorted
|
|
||||||
sort.Sort(byName(dockerCommands))
|
|
||||||
|
|
||||||
for _, cmd := range dockerCommands {
|
for _, cmd := range dockerCommands {
|
||||||
help += fmt.Sprintf(" %-10.10s%s\n", cmd.name, cmd.description)
|
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"},
|
{"login", "Register or log in to a Docker registry"},
|
||||||
{"logout", "Log out from a Docker registry"},
|
{"logout", "Log out from a Docker registry"},
|
||||||
{"logs", "Fetch the logs of a container"},
|
{"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"},
|
{"pause", "Pause all processes within a container"},
|
||||||
|
{"port", "List port mappings or a specific mapping for the CONTAINER"},
|
||||||
{"ps", "List containers"},
|
{"ps", "List containers"},
|
||||||
{"pull", "Pull an image or a repository from a registry"},
|
{"pull", "Pull an image or a repository from a registry"},
|
||||||
{"push", "Push an image or a repository to a registry"},
|
{"push", "Push an image or a repository to a registry"},
|
||||||
|
|
13
docker/flags_test.go
Normal file
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")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue