MCPcopy
hub / github.com/kubernetes/client-go / TestConflictingCurrentContext

Function TestConflictingCurrentContext

tools/clientcmd/loader_test.go:147–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestConflictingCurrentContext(t *testing.T) {
148 commandLineFile, _ := ioutil.TempFile("", "")
149 defer os.Remove(commandLineFile.Name())
150 envVarFile, _ := ioutil.TempFile("", "")
151 defer os.Remove(envVarFile.Name())
152
153 mockCommandLineConfig := clientcmdapi.Config{
154 CurrentContext: "any-context-value",
155 }
156 mockEnvVarConfig := clientcmdapi.Config{
157 CurrentContext: "a-different-context",
158 }
159
160 WriteToFile(mockCommandLineConfig, commandLineFile.Name())
161 WriteToFile(mockEnvVarConfig, envVarFile.Name())
162
163 loadingRules := ClientConfigLoadingRules{
164 ExplicitPath: commandLineFile.Name(),
165 Precedence: []string{envVarFile.Name()},
166 }
167
168 mergedConfig, err := loadingRules.Load()
169 if err != nil {
170 t.Errorf("Unexpected error: %v", err)
171 }
172
173 if mergedConfig.CurrentContext != mockCommandLineConfig.CurrentContext {
174 t.Errorf("expected %v, got %v", mockCommandLineConfig.CurrentContext, mergedConfig.CurrentContext)
175 }
176}
177
178func TestLoadingEmptyMaps(t *testing.T) {
179 configFile, _ := ioutil.TempFile("", "")

Callers

nothing calls this directly

Calls 4

LoadMethod · 0.95
WriteToFileFunction · 0.85
ErrorfMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected