MCPcopy Index your code
hub / github.com/fsouza/go-dockerclient / TestCreateContainerWithNotifyChannel

Function TestCreateContainerWithNotifyChannel

testing/server_test.go:352–370  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

350}
351
352func TestCreateContainerWithNotifyChannel(t *testing.T) {
353 t.Parallel()
354 ch := make(chan *docker.Container, 1)
355 server := baseDockerServer()
356 server.imgIDs = map[string]string{"base": "a1234"}
357 server.cChan = ch
358 server.buildMuxer()
359 recorder := httptest.NewRecorder()
360 body := `{"Hostname":"", "User":"", "Memory":0, "MemorySwap":0, "AttachStdin":false, "AttachStdout":true, "AttachStderr":true,
361"PortSpecs":null, "Tty":false, "OpenStdin":false, "StdinOnce":false, "Env":null, "Cmd":["date"], "Image":"base", "Volumes":{}, "VolumesFrom":""}`
362 request, _ := http.NewRequest(http.MethodPost, "/containers/create", strings.NewReader(body))
363 server.ServeHTTP(recorder, request)
364 if recorder.Code != http.StatusCreated {
365 t.Errorf("CreateContainer: wrong status. Want %d. Got %d.", http.StatusCreated, recorder.Code)
366 }
367 if notified := <-ch; notified != getContainer(&server) {
368 t.Errorf("CreateContainer: did not notify the proper container. Want %q. Got %q.", getContainer(&server).ID, notified.ID)
369 }
370}
371
372func TestCreateContainerInvalidBody(t *testing.T) {
373 t.Parallel()

Callers

nothing calls this directly

Calls 4

baseDockerServerFunction · 0.85
getContainerFunction · 0.85
buildMuxerMethod · 0.80
ServeHTTPMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…