(t *testing.T)
| 170 | } |
| 171 | |
| 172 | func TestParseGitHubToolsetsDeduplication(t *testing.T) { |
| 173 | toolsetPermissionsMap := getToolsetPermissionsMap() |
| 174 | |
| 175 | tests := []struct { |
| 176 | name string |
| 177 | input string |
| 178 | expected int |
| 179 | }{ |
| 180 | { |
| 181 | name: "Duplicate in simple list", |
| 182 | input: "repos,issues,repos,issues", |
| 183 | expected: 2, |
| 184 | }, |
| 185 | { |
| 186 | name: "Default includes duplicates", |
| 187 | input: "context,default", |
| 188 | expected: 4, // context already in default, so only 4 unique |
| 189 | }, |
| 190 | { |
| 191 | name: "All with duplicates", |
| 192 | input: "all,repos,issues", |
| 193 | expected: len(toolsetPermissionsMap) - len(GitHubToolsetsExcludedFromAll), // All toolsets minus excluded, duplicates ignored |
| 194 | }, |
| 195 | } |
| 196 | |
| 197 | for _, tt := range tests { |
| 198 | t.Run(tt.name, func(t *testing.T) { |
| 199 | result := ParseGitHubToolsets(tt.input) |
| 200 | if len(result) != tt.expected { |
| 201 | t.Errorf("Expected %d unique toolsets, got %d: %v", tt.expected, len(result), result) |
| 202 | } |
| 203 | |
| 204 | // Verify no duplicates |
| 205 | seen := make(map[string]struct{}) |
| 206 | for _, toolset := range result { |
| 207 | if _, ok := seen[toolset]; ok { |
| 208 | t.Errorf("Found duplicate toolset: %s", toolset) |
| 209 | } |
| 210 | seen[toolset] = struct{}{} |
| 211 | } |
| 212 | }) |
| 213 | } |
| 214 | } |
nothing calls this directly
no test coverage detected