(t *testing.T)
| 144 | } |
| 145 | |
| 146 | func 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 | |
| 178 | func TestInitConfigCLIOverridesConfigFile(t *testing.T) { |
| 179 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected