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

Function TestNewDockerCliWithCustomUserAgent

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

Source from the content-addressed store, hash-verified

372}
373
374func TestNewDockerCliWithCustomUserAgent(t *testing.T) {
375 var received string
376 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
377 received = r.UserAgent()
378 w.WriteHeader(http.StatusOK)
379 }))
380 defer ts.Close()
381 host := strings.Replace(ts.URL, "http://", "tcp://", 1)
382 opts := &flags.ClientOptions{Hosts: []string{host}}
383
384 cli, err := NewDockerCli(
385 WithUserAgent("fake-agent/0.0.1"),
386 )
387 assert.NilError(t, err)
388 cli.currentContext = DefaultContextName
389 cli.options = opts
390 cli.configFile = &configfile.ConfigFile{}
391
392 _, err = cli.Client().Ping(context.TODO(), client.PingOptions{})
393 assert.NilError(t, err)
394 assert.DeepEqual(t, received, "fake-agent/0.0.1")
395}
396
397func TestNewDockerCliWithAPIClientOptions(t *testing.T) {
398 var received string

Callers

nothing calls this directly

Calls 5

ClientMethod · 0.95
NewDockerCliFunction · 0.85
WithUserAgentFunction · 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…