(t *testing.T)
| 372 | } |
| 373 | |
| 374 | func 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 | |
| 397 | func TestNewDockerCliWithAPIClientOptions(t *testing.T) { |
| 398 | var received string |
nothing calls this directly
no test coverage detected
searching dependent graphs…