mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
update vendor/ dir to latest w/o heroku, moby
had to lock a lot of things in place
This commit is contained in:
88
vendor/github.com/fsouza/go-dockerclient/container_test.go
generated
vendored
88
vendor/github.com/fsouza/go-dockerclient/container_test.go
generated
vendored
@@ -26,6 +26,7 @@ import (
|
||||
)
|
||||
|
||||
func TestStateString(t *testing.T) {
|
||||
t.Parallel()
|
||||
started := time.Now().Add(-3 * time.Hour)
|
||||
var tests = []struct {
|
||||
input State
|
||||
@@ -48,6 +49,7 @@ func TestStateString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStateStateString(t *testing.T) {
|
||||
t.Parallel()
|
||||
started := time.Now().Add(-3 * time.Hour)
|
||||
var tests = []struct {
|
||||
input State
|
||||
@@ -68,6 +70,7 @@ func TestStateStateString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListContainers(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainers := `[
|
||||
{
|
||||
"Id": "8dfafdbc3a40",
|
||||
@@ -118,6 +121,7 @@ func TestListContainers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListContainersParams(t *testing.T) {
|
||||
t.Parallel()
|
||||
var tests = []struct {
|
||||
input ListContainersOptions
|
||||
params map[string][]string
|
||||
@@ -160,6 +164,7 @@ func TestListContainersParams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListContainersFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
var tests = []struct {
|
||||
status int
|
||||
message string
|
||||
@@ -181,6 +186,7 @@ func TestListContainersFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInspectContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainer := `{
|
||||
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
||||
"AppArmorProfile": "Profile",
|
||||
@@ -290,6 +296,7 @@ func TestInspectContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInspectContainerWithContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainer := `{
|
||||
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
||||
"AppArmorProfile": "Profile",
|
||||
@@ -435,6 +442,7 @@ func TestInspectContainerWithContext(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInspectContainerNetwork(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainer := `{
|
||||
"Id": "81e1bbe20b5508349e1c804eb08b7b6ca8366751dbea9f578b3ea0773fa66c1c",
|
||||
"Created": "2015-11-12T14:54:04.791485659Z",
|
||||
@@ -678,6 +686,7 @@ func TestInspectContainerNetwork(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInspectContainerNegativeSwap(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainer := `{
|
||||
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
||||
"Created": "2013-05-07T14:51:42.087658+02:00",
|
||||
@@ -760,6 +769,7 @@ func TestInspectContainerNegativeSwap(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInspectContainerFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "server error", status: 500})
|
||||
expected := Error{Status: 500, Message: "server error"}
|
||||
container, err := client.InspectContainer("abe033")
|
||||
@@ -772,6 +782,7 @@ func TestInspectContainerFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInspectContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: 404})
|
||||
container, err := client.InspectContainer("abe033")
|
||||
if container != nil {
|
||||
@@ -784,6 +795,7 @@ func TestInspectContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestContainerChanges(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonChanges := `[
|
||||
{
|
||||
"Path":"/dev",
|
||||
@@ -820,6 +832,7 @@ func TestContainerChanges(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestContainerChangesFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "server error", status: 500})
|
||||
expected := Error{Status: 500, Message: "server error"}
|
||||
changes, err := client.ContainerChanges("abe033")
|
||||
@@ -832,6 +845,7 @@ func TestContainerChangesFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestContainerChangesNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: 404})
|
||||
changes, err := client.ContainerChanges("abe033")
|
||||
if changes != nil {
|
||||
@@ -844,6 +858,7 @@ func TestContainerChangesNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainer := `{
|
||||
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
||||
"Warnings": []
|
||||
@@ -881,6 +896,7 @@ func TestCreateContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateContainerImageNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "No such image", status: http.StatusNotFound})
|
||||
config := Config{AttachStdout: true, AttachStdin: true}
|
||||
container, err := client.CreateContainer(CreateContainerOptions{Config: &config})
|
||||
@@ -893,6 +909,7 @@ func TestCreateContainerImageNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateContainerDuplicateName(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "No such image", status: http.StatusConflict})
|
||||
config := Config{AttachStdout: true, AttachStdin: true}
|
||||
container, err := client.CreateContainer(CreateContainerOptions{Config: &config})
|
||||
@@ -905,6 +922,7 @@ func TestCreateContainerDuplicateName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateContainerWithHostConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "{}", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
config := Config{}
|
||||
@@ -926,6 +944,7 @@ func TestCreateContainerWithHostConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -956,6 +975,7 @@ func TestUpdateContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -978,6 +998,7 @@ func TestStartContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainerHostConfigAPI124(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
client.serverAPIVersion = apiVersion124
|
||||
@@ -1005,6 +1026,7 @@ func TestStartContainerHostConfigAPI124(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainerNilHostConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1032,6 +1054,7 @@ func TestStartContainerNilHostConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainerWithContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1067,6 +1090,7 @@ func TestStartContainerWithContext(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.StartContainer("a2344", &HostConfig{})
|
||||
expected := &NoSuchContainer{ID: "a2344", Err: err.(*NoSuchContainer).Err}
|
||||
@@ -1076,6 +1100,7 @@ func TestStartContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainerAlreadyRunning(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "container already running", status: http.StatusNotModified})
|
||||
err := client.StartContainer("a2334", &HostConfig{})
|
||||
expected := &ContainerAlreadyRunning{ID: "a2334"}
|
||||
@@ -1085,6 +1110,7 @@ func TestStartContainerAlreadyRunning(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1103,6 +1129,7 @@ func TestStopContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopContainerWithContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1134,6 +1161,7 @@ func TestStopContainerWithContext(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.StopContainer("a2334", 10)
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1143,6 +1171,7 @@ func TestStopContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopContainerNotRunning(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "container not running", status: http.StatusNotModified})
|
||||
err := client.StopContainer("a2334", 10)
|
||||
expected := &ContainerNotRunning{ID: "a2334"}
|
||||
@@ -1152,6 +1181,7 @@ func TestStopContainerNotRunning(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestartContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1170,6 +1200,7 @@ func TestRestartContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestartContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.RestartContainer("a2334", 10)
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1179,6 +1210,7 @@ func TestRestartContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPauseContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1197,6 +1229,7 @@ func TestPauseContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPauseContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.PauseContainer("a2334")
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1206,6 +1239,7 @@ func TestPauseContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnpauseContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1224,6 +1258,7 @@ func TestUnpauseContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnpauseContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.UnpauseContainer("a2334")
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1233,6 +1268,7 @@ func TestUnpauseContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKillContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1251,6 +1287,7 @@ func TestKillContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKillContainerSignal(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusNoContent}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1268,6 +1305,7 @@ func TestKillContainerSignal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKillContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.KillContainer(KillContainerOptions{ID: "a2334"})
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1277,6 +1315,7 @@ func TestKillContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1296,6 +1335,7 @@ func TestRemoveContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveContainerRemoveVolumes(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1313,6 +1353,7 @@ func TestRemoveContainerRemoveVolumes(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRemoveContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
err := client.RemoveContainer(RemoveContainerOptions{ID: "a2334"})
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1322,6 +1363,7 @@ func TestRemoveContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResizeContainerTTY(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1348,6 +1390,7 @@ func TestResizeContainerTTY(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWaitContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: `{"StatusCode": 56}`, status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1369,6 +1412,7 @@ func TestWaitContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWaitContainerWithContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: `{"StatusCode": 56}`, status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
id := "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2"
|
||||
@@ -1406,6 +1450,7 @@ func TestWaitContainerWithContext(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWaitContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
_, err := client.WaitContainer("a2334")
|
||||
expected := &NoSuchContainer{ID: "a2334"}
|
||||
@@ -1415,6 +1460,7 @@ func TestWaitContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommitContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
response := `{"Id":"596069db4bf5"}`
|
||||
client := newTestClient(&FakeRoundTripper{message: response, status: http.StatusOK})
|
||||
id := "596069db4bf5"
|
||||
@@ -1428,6 +1474,7 @@ func TestCommitContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommitContainerParams(t *testing.T) {
|
||||
t.Parallel()
|
||||
cfg := Config{Memory: 67108864}
|
||||
json, _ := json.Marshal(&cfg)
|
||||
var tests = []struct {
|
||||
@@ -1479,6 +1526,7 @@ func TestCommitContainerParams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommitContainerFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusInternalServerError})
|
||||
_, err := client.CommitContainer(CommitContainerOptions{})
|
||||
if err == nil {
|
||||
@@ -1487,6 +1535,7 @@ func TestCommitContainerFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCommitContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
_, err := client.CommitContainer(CommitContainerOptions{})
|
||||
expected := &NoSuchContainer{ID: ""}
|
||||
@@ -1496,6 +1545,7 @@ func TestCommitContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerLogs(t *testing.T) {
|
||||
t.Parallel()
|
||||
var req http.Request
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte{1, 0, 0, 0, 0, 0, 0, 19})
|
||||
@@ -1540,6 +1590,7 @@ func TestAttachToContainerLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
var reader = strings.NewReader("send value")
|
||||
var req http.Request
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -1579,6 +1630,7 @@ func TestAttachToContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerSentinel(t *testing.T) {
|
||||
t.Parallel()
|
||||
var reader = strings.NewReader("send value")
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte{1, 0, 0, 0, 0, 0, 0, 5})
|
||||
@@ -1612,6 +1664,7 @@ func TestAttachToContainerSentinel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerNilStdout(t *testing.T) {
|
||||
t.Parallel()
|
||||
var reader = strings.NewReader("send value")
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte{1, 0, 0, 0, 0, 0, 0, 5})
|
||||
@@ -1639,6 +1692,7 @@ func TestAttachToContainerNilStdout(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerNilStderr(t *testing.T) {
|
||||
t.Parallel()
|
||||
var reader = strings.NewReader("send value")
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte{1, 0, 0, 0, 0, 0, 0, 5})
|
||||
@@ -1665,6 +1719,7 @@ func TestAttachToContainerNilStderr(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerStdinOnly(t *testing.T) {
|
||||
t.Parallel()
|
||||
var reader = strings.NewReader("send value")
|
||||
serverFinished := make(chan struct{})
|
||||
clientFinished := make(chan struct{})
|
||||
@@ -1711,6 +1766,7 @@ func TestAttachToContainerStdinOnly(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerRawTerminalFalse(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := strings.NewReader("send value")
|
||||
var req http.Request
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -1766,6 +1822,7 @@ func TestAttachToContainerRawTerminalFalse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAttachToContainerWithoutContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
var client Client
|
||||
err := client.AttachToContainer(AttachToContainerOptions{})
|
||||
expected := &NoSuchContainer{ID: ""}
|
||||
@@ -1775,6 +1832,7 @@ func TestAttachToContainerWithoutContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLogs(t *testing.T) {
|
||||
t.Parallel()
|
||||
var req http.Request
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
prefix := []byte{1, 0, 0, 0, 0, 0, 0, 19}
|
||||
@@ -1823,6 +1881,7 @@ func TestLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLogsNilStdoutDoesntFail(t *testing.T) {
|
||||
t.Parallel()
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
prefix := []byte{1, 0, 0, 0, 0, 0, 0, 19}
|
||||
w.Write(prefix)
|
||||
@@ -1845,6 +1904,7 @@ func TestLogsNilStdoutDoesntFail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLogsNilStderrDoesntFail(t *testing.T) {
|
||||
t.Parallel()
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
prefix := []byte{2, 0, 0, 0, 0, 0, 0, 19}
|
||||
w.Write(prefix)
|
||||
@@ -1867,6 +1927,7 @@ func TestLogsNilStderrDoesntFail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLogsSpecifyingTail(t *testing.T) {
|
||||
t.Parallel()
|
||||
var req http.Request
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
prefix := []byte{1, 0, 0, 0, 0, 0, 0, 19}
|
||||
@@ -1916,6 +1977,7 @@ func TestLogsSpecifyingTail(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLogsRawTerminal(t *testing.T) {
|
||||
t.Parallel()
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("something happened!"))
|
||||
}))
|
||||
@@ -1944,6 +2006,7 @@ func TestLogsRawTerminal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLogsNoContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
var client Client
|
||||
err := client.Logs(LogsOptions{})
|
||||
expected := &NoSuchContainer{ID: ""}
|
||||
@@ -1953,6 +2016,7 @@ func TestLogsNoContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoSuchContainerError(t *testing.T) {
|
||||
t.Parallel()
|
||||
var err = &NoSuchContainer{ID: "i345"}
|
||||
expected := "No such container: i345"
|
||||
if got := err.Error(); got != expected {
|
||||
@@ -1961,6 +2025,7 @@ func TestNoSuchContainerError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoSuchContainerErrorMessage(t *testing.T) {
|
||||
t.Parallel()
|
||||
var err = &NoSuchContainer{ID: "i345", Err: errors.New("some advanced error info")}
|
||||
expected := "some advanced error info"
|
||||
if got := err.Error(); got != expected {
|
||||
@@ -1969,6 +2034,7 @@ func TestNoSuchContainerErrorMessage(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExportContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
content := "exported container tar content"
|
||||
out := stdoutMock{bytes.NewBufferString(content)}
|
||||
client := newTestClient(&FakeRoundTripper{status: http.StatusOK})
|
||||
@@ -2015,6 +2081,7 @@ func tempfile(filename string) string {
|
||||
}
|
||||
|
||||
func TestExportContainerNoId(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := Client{}
|
||||
out := stdoutMock{bytes.NewBufferString("")}
|
||||
err := client.ExportContainer(ExportContainerOptions{OutputStream: out})
|
||||
@@ -2028,6 +2095,7 @@ func TestExportContainerNoId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUploadToContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
content := "File content"
|
||||
in := stdinMock{bytes.NewBufferString(content)}
|
||||
fakeRT := &FakeRoundTripper{status: http.StatusOK}
|
||||
@@ -2054,6 +2122,7 @@ func TestUploadToContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDownloadFromContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
filecontent := "File content"
|
||||
client := newTestClient(&FakeRoundTripper{message: filecontent, status: http.StatusOK})
|
||||
|
||||
@@ -2071,6 +2140,7 @@ func TestDownloadFromContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyFromContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
content := "File content"
|
||||
out := stdoutMock{bytes.NewBufferString(content)}
|
||||
client := newTestClient(&FakeRoundTripper{status: http.StatusOK})
|
||||
@@ -2088,6 +2158,7 @@ func TestCopyFromContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyFromContainerEmptyContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{status: http.StatusOK})
|
||||
err := client.CopyFromContainer(CopyFromContainerOptions{})
|
||||
_, ok := err.(*NoSuchContainer)
|
||||
@@ -2097,6 +2168,7 @@ func TestCopyFromContainerEmptyContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyFromContainerDockerAPI124(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{status: http.StatusOK})
|
||||
client.serverAPIVersion = apiVersion124
|
||||
opts := CopyFromContainerOptions{
|
||||
@@ -2113,6 +2185,7 @@ func TestCopyFromContainerDockerAPI124(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPassingNameOptToCreateContainerReturnsItInContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonContainer := `{
|
||||
"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
|
||||
"Warnings": []
|
||||
@@ -2131,6 +2204,7 @@ func TestPassingNameOptToCreateContainerReturnsItInContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAlwaysRestart(t *testing.T) {
|
||||
t.Parallel()
|
||||
policy := AlwaysRestart()
|
||||
if policy.Name != "always" {
|
||||
t.Errorf("AlwaysRestart(): wrong policy name. Want %q. Got %q", "always", policy.Name)
|
||||
@@ -2141,6 +2215,7 @@ func TestAlwaysRestart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestartOnFailure(t *testing.T) {
|
||||
t.Parallel()
|
||||
const retry = 5
|
||||
policy := RestartOnFailure(retry)
|
||||
if policy.Name != "on-failure" {
|
||||
@@ -2152,6 +2227,7 @@ func TestRestartOnFailure(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRestartUnlessStopped(t *testing.T) {
|
||||
t.Parallel()
|
||||
policy := RestartUnlessStopped()
|
||||
if policy.Name != "unless-stopped" {
|
||||
t.Errorf("RestartUnlessStopped(): wrong policy name. Want %q. Got %q", "unless-stopped", policy.Name)
|
||||
@@ -2162,6 +2238,7 @@ func TestRestartUnlessStopped(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNeverRestart(t *testing.T) {
|
||||
t.Parallel()
|
||||
policy := NeverRestart()
|
||||
if policy.Name != "no" {
|
||||
t.Errorf("NeverRestart(): wrong policy name. Want %q. Got %q", "always", policy.Name)
|
||||
@@ -2172,6 +2249,7 @@ func TestNeverRestart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTopContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonTop := `{
|
||||
"Processes": [
|
||||
[
|
||||
@@ -2232,6 +2310,7 @@ func TestTopContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTopContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
_, err := client.TopContainer("abef348", "")
|
||||
expected := &NoSuchContainer{ID: "abef348"}
|
||||
@@ -2241,6 +2320,7 @@ func TestTopContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTopContainerWithPsArgs(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "no such container", status: http.StatusNotFound}
|
||||
client := newTestClient(fakeRT)
|
||||
expectedErr := &NoSuchContainer{ID: "abef348"}
|
||||
@@ -2254,6 +2334,7 @@ func TestTopContainerWithPsArgs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStats(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonStats1 := `{
|
||||
"read" : "2015-01-08T22:57:31.547920715Z",
|
||||
"network" : {
|
||||
@@ -2561,6 +2642,7 @@ func TestStats(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStatsContainerNotFound(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||
statsC := make(chan *Stats)
|
||||
done := make(chan bool)
|
||||
@@ -2573,6 +2655,7 @@ func TestStatsContainerNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRenameContainer(t *testing.T) {
|
||||
t.Parallel()
|
||||
fakeRT := &FakeRoundTripper{message: "", status: http.StatusOK}
|
||||
client := newTestClient(fakeRT)
|
||||
opts := RenameContainerOptions{ID: "something_old", Name: "something_new"}
|
||||
@@ -2607,6 +2690,7 @@ func (rt *sleepyRoudTripper) RoundTrip(r *http.Request) (*http.Response, error)
|
||||
}
|
||||
|
||||
func TestInspectContainerWhenContextTimesOut(t *testing.T) {
|
||||
t.Parallel()
|
||||
rt := sleepyRoudTripper{sleepDuration: 200 * time.Millisecond}
|
||||
|
||||
client := newTestClient(&rt)
|
||||
@@ -2621,6 +2705,7 @@ func TestInspectContainerWhenContextTimesOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStartContainerWhenContextTimesOut(t *testing.T) {
|
||||
t.Parallel()
|
||||
rt := sleepyRoudTripper{sleepDuration: 200 * time.Millisecond}
|
||||
|
||||
client := newTestClient(&rt)
|
||||
@@ -2635,6 +2720,7 @@ func TestStartContainerWhenContextTimesOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopContainerWhenContextTimesOut(t *testing.T) {
|
||||
t.Parallel()
|
||||
rt := sleepyRoudTripper{sleepDuration: 200 * time.Millisecond}
|
||||
|
||||
client := newTestClient(&rt)
|
||||
@@ -2649,6 +2735,7 @@ func TestStopContainerWhenContextTimesOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWaitContainerWhenContextTimesOut(t *testing.T) {
|
||||
t.Parallel()
|
||||
rt := sleepyRoudTripper{sleepDuration: 200 * time.Millisecond}
|
||||
|
||||
client := newTestClient(&rt)
|
||||
@@ -2663,6 +2750,7 @@ func TestWaitContainerWhenContextTimesOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPruneContainers(t *testing.T) {
|
||||
t.Parallel()
|
||||
results := `{
|
||||
"ContainersDeleted": [
|
||||
"a", "b", "c"
|
||||
|
||||
Reference in New Issue
Block a user