(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestUseHostOverride(t *testing.T) { |
| 85 | t.Setenv("DOCKER_HOST", "tcp://ed:2375/") |
| 86 | |
| 87 | configDir := t.TempDir() |
| 88 | configFilePath := filepath.Join(configDir, "config.json") |
| 89 | testCfg := configfile.New(configFilePath) |
| 90 | cli := makeFakeCli(t, withCliConfig(testCfg)) |
| 91 | err := runCreate(cli, "test", createOptions{ |
| 92 | endpoint: map[string]string{}, |
| 93 | }) |
| 94 | assert.NilError(t, err) |
| 95 | |
| 96 | cli.ResetOutputBuffers() |
| 97 | err = newUseCommand(cli).RunE(nil, []string{"test"}) |
| 98 | assert.NilError(t, err) |
| 99 | assert.Assert(t, is.Contains( |
| 100 | cli.ErrBuffer().String(), |
| 101 | `Warning: DOCKER_HOST environment variable overrides the active context.`, |
| 102 | )) |
| 103 | assert.Assert(t, is.Contains(cli.ErrBuffer().String(), `Current context is now "test"`)) |
| 104 | assert.Equal(t, cli.OutBuffer().String(), "test\n") |
| 105 | |
| 106 | // setting DOCKER_HOST with the default context should not print a warning |
| 107 | cli.ResetOutputBuffers() |
| 108 | err = newUseCommand(cli).RunE(nil, []string{"default"}) |
| 109 | assert.NilError(t, err) |
| 110 | assert.Assert(t, is.Contains(cli.ErrBuffer().String(), `Current context is now "default"`)) |
| 111 | assert.Equal(t, cli.OutBuffer().String(), "default\n") |
| 112 | } |
| 113 | |
| 114 | // An empty DOCKER_HOST used to break the 'context use' flow. |
| 115 | // So we have a test with fewer fakes that tests this flow holistically. |
nothing calls this directly
no test coverage detected
searching dependent graphs…