MCPcopy Index your code
hub / github.com/docker/cli / TestNewDockerCliWithAPIClientOptions

Function TestNewDockerCliWithAPIClientOptions

cli/command/cli_test.go:397–418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func TestNewDockerCliWithAPIClientOptions(t *testing.T) {
398 var received string
399 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
400 received = r.UserAgent()
401 w.WriteHeader(http.StatusOK)
402 }))
403 defer ts.Close()
404 host := strings.Replace(ts.URL, "http://", "tcp://", 1)
405 opts := &flags.ClientOptions{Hosts: []string{host}}
406
407 cli, err := NewDockerCli(
408 WithAPIClientOptions(client.WithUserAgent("fake-agent/0.0.1")),
409 )
410 assert.NilError(t, err)
411 cli.currentContext = DefaultContextName
412 cli.options = opts
413 cli.configFile = &configfile.ConfigFile{}
414
415 _, err = cli.Client().Ping(t.Context(), client.PingOptions{})
416 assert.NilError(t, err)
417 assert.DeepEqual(t, received, "fake-agent/0.0.1")
418}

Callers

nothing calls this directly

Calls 5

ClientMethod · 0.95
NewDockerCliFunction · 0.85
WithAPIClientOptionsFunction · 0.85
CloseMethod · 0.45
PingMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…