MCPcopy Create free account
hub / github.com/amitsaha/gitbackup / TestInitConfigCLIOverridesConfigFile

Function TestInitConfigCLIOverridesConfigFile

config_file_test.go:178–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

176}
177
178func TestInitConfigCLIOverridesConfigFile(t *testing.T) {
179 tmpDir := t.TempDir()
180 configPath := filepath.Join(tmpDir, defaultConfigFile)
181
182 // Config file says gitlab with ignore_fork true
183 os.WriteFile(configPath, []byte("service: gitlab\nignore_fork: true\ngitlab:\n project_visibility: private\n project_membership_type: all\n"), 0644)
184 os.Setenv("GITLAB_TOKEN", "testtoken")
185 defer os.Unsetenv("GITLAB_TOKEN")
186
187 // CLI flag overrides service to github
188 c, err := buildTestConfig([]string{"-config", configPath, "-service", "github"})
189 if err != nil {
190 t.Fatalf("Expected no error, got: %v", err)
191 }
192
193 // service should be overridden by CLI flag
194 if c.service != "github" {
195 t.Errorf("Expected service 'github' from CLI flag, got: %v", c.service)
196 }
197 // ignore_fork should still be true from config file (not overridden)
198 if !c.ignoreFork {
199 t.Error("Expected ignore_fork to be true from config file")
200 }
201}
202
203func TestInitConfigNoConfigFile(t *testing.T) {
204 // No config file — should behave exactly as before

Callers

nothing calls this directly

Calls 1

buildTestConfigFunction · 0.85

Tested by

no test coverage detected