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

Function TestInitConfigWithConfigFile

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

Source from the content-addressed store, hash-verified

144}
145
146func TestInitConfigWithConfigFile(t *testing.T) {
147 tmpDir := t.TempDir()
148 configPath := filepath.Join(tmpDir, defaultConfigFile)
149
150 // Write a config file with specific values
151 os.WriteFile(configPath, []byte("service: gitlab\nignore_fork: true\nuse_https_clone: true\ngitlab:\n project_visibility: private\n project_membership_type: owner\n"), 0644)
152 os.Setenv("GITLAB_TOKEN", "testtoken")
153 defer os.Unsetenv("GITLAB_TOKEN")
154
155 // buildTestConfig with --config flag should use config file values
156 c, err := buildTestConfig([]string{"-config", configPath})
157 if err != nil {
158 t.Fatalf("Expected no error, got: %v", err)
159 }
160
161 if c.service != "gitlab" {
162 t.Errorf("Expected service 'gitlab', got: %v", c.service)
163 }
164 if !c.ignoreFork {
165 t.Error("Expected ignore_fork to be true from config file")
166 }
167 if !c.useHTTPSClone {
168 t.Error("Expected use_https_clone to be true from config file")
169 }
170 if c.gitlabProjectVisibility != "private" {
171 t.Errorf("Expected project_visibility 'private', got: %v", c.gitlabProjectVisibility)
172 }
173 if c.gitlabProjectMembershipType != "owner" {
174 t.Errorf("Expected project_membership_type 'owner', got: %v", c.gitlabProjectMembershipType)
175 }
176}
177
178func TestInitConfigCLIOverridesConfigFile(t *testing.T) {
179 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 1

buildTestConfigFunction · 0.85

Tested by

no test coverage detected