MCPcopy Create free account
hub / github.com/github/gh-aw / TestAddUniqueWorkflow

Function TestAddUniqueWorkflow

pkg/cli/logs_report_test.go:194–246  ·  view source on GitHub ↗

TestAddUniqueWorkflow tests the workflow deduplication helper

(t *testing.T)

Source from the content-addressed store, hash-verified

192
193// TestAddUniqueWorkflow tests the workflow deduplication helper
194func 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
249func TestBuildMissingToolsSummaryDeduplication(t *testing.T) {

Callers

nothing calls this directly

Calls 3

MergeUniqueFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected