mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
03504cab65
1. replaced --net option for service UI with SERVICE.[NETWORK] format 2. Making using of the default network/driver backend support 3. NetworkName and NetworkType from the UI/API can be empty string and it will be replaced with DefaultNetwork and DefaultDriver As per the design goals, we wanted to keep libnetwork core free of handling defaults. Rather, the clients (docker & dnet) must handle the defaultness of these entities. Also, since there is no API to get these Default values from the backend, UI will not handle the default values either. Hence, this falls under the responsibility of the API layer to handle this specific case. Signed-off-by: Madhu Venugopal <madhu@docker.com>
122 lines
3 KiB
Go
122 lines
3 KiB
Go
package client
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
_ "github.com/docker/libnetwork/netutils"
|
|
)
|
|
|
|
func TestClientServiceInvalidCommand(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "invalid")
|
|
if err == nil {
|
|
t.Fatalf("Passing invalid commands must fail")
|
|
}
|
|
}
|
|
|
|
func TestClientServiceCreate(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "publish", mockServiceName+"."+mockNwName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestClientServiceRm(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "unpublish", mockServiceName+"."+mockNwName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestClientServiceLs(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "ls")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestClientServiceInfo(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "info", mockServiceName+"."+mockNwName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestClientServiceInfoById(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "info", mockServiceID+"."+mockNwName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestClientServiceJoin(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "attach", mockContainerID, mockServiceName+"."+mockNwName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestClientServiceLeave(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "service", "detach", mockContainerID, mockServiceName+"."+mockNwName)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// Docker Flag processing in flag.go uses os.Exit() frequently, even for --help
|
|
// TODO : Handle the --help test-case in the IT when CLI is available
|
|
/*
|
|
func TestClientNetworkServiceCreateHelp(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cFunc := func(method, path string, data interface{}, headers map[string][]string) (io.ReadCloser, int, error) {
|
|
return nil, 0, nil
|
|
}
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "network", "create", "--help")
|
|
if err != nil {
|
|
t.Fatalf(err.Error())
|
|
}
|
|
}
|
|
*/
|
|
|
|
// Docker flag processing in flag.go uses os.Exit(1) for incorrect parameter case.
|
|
// TODO : Handle the missing argument case in the IT when CLI is available
|
|
/*
|
|
func TestClientNetworkServiceCreateMissingArgument(t *testing.T) {
|
|
var out, errOut bytes.Buffer
|
|
cFunc := func(method, path string, data interface{}, headers map[string][]string) (io.ReadCloser, int, error) {
|
|
return nil, 0, nil
|
|
}
|
|
cli := NewNetworkCli(&out, &errOut, callbackFunc)
|
|
|
|
err := cli.Cmd("docker", "network", "create")
|
|
if err != nil {
|
|
t.Fatal(err.Error())
|
|
}
|
|
}
|
|
*/
|