TestAddUniqueWorkflow tests the workflow deduplication helper
(t *testing.T)
| 192 | |
| 193 | // TestAddUniqueWorkflow tests the workflow deduplication helper |
| 194 | func TestAddUniqueWorkflow(t *testing.T) { |
| 195 | tests := []struct { |
| 196 | name string |
| 197 | workflows []string |
| 198 | workflow string |
| 199 | expected []string |
| 200 | }{ |
| 201 | { |
| 202 | name: "add to empty list", |
| 203 | workflows: []string{}, |
| 204 | workflow: "workflow-a", |
| 205 | expected: []string{"workflow-a"}, |
| 206 | }, |
| 207 | { |
| 208 | name: "add new workflow", |
| 209 | workflows: []string{"workflow-a", "workflow-b"}, |
| 210 | workflow: "workflow-c", |
| 211 | expected: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 212 | }, |
| 213 | { |
| 214 | name: "duplicate workflow at beginning", |
| 215 | workflows: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 216 | workflow: "workflow-a", |
| 217 | expected: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 218 | }, |
| 219 | { |
| 220 | name: "duplicate workflow in middle", |
| 221 | workflows: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 222 | workflow: "workflow-b", |
| 223 | expected: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 224 | }, |
| 225 | { |
| 226 | name: "duplicate workflow at end", |
| 227 | workflows: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 228 | workflow: "workflow-c", |
| 229 | expected: []string{"workflow-a", "workflow-b", "workflow-c"}, |
| 230 | }, |
| 231 | } |
| 232 | |
| 233 | for _, tt := range tests { |
| 234 | t.Run(tt.name, func(t *testing.T) { |
| 235 | result := sliceutil.MergeUnique(tt.workflows, tt.workflow) |
| 236 | if len(result) != len(tt.expected) { |
| 237 | t.Errorf("Expected length %d, got %d", len(tt.expected), len(result)) |
| 238 | } |
| 239 | for i, wf := range result { |
| 240 | if wf != tt.expected[i] { |
| 241 | t.Errorf("Expected workflow[%d] = %s, got %s", i, tt.expected[i], wf) |
| 242 | } |
| 243 | } |
| 244 | }) |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // TestBuildMissingToolsSummaryDeduplication tests that workflow deduplication works correctly |
| 249 | func TestBuildMissingToolsSummaryDeduplication(t *testing.T) { |
nothing calls this directly
no test coverage detected