(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func 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 | |
| 178 | func TestLoadingEmptyMaps(t *testing.T) { |
| 179 | configFile, _ := ioutil.TempFile("", "") |
nothing calls this directly
no test coverage detected