Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/actionpins/actionpins_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ func TestInitWarnings_InitializesAndPreservesMap(t *testing.T) {
})

t.Run("preserves existing warnings map", func(t *testing.T) {
existing := map[string]bool{"actions/checkout@v5": true}
ctx := &PinContext{Warnings: existing}
existing := map[string]struct{}{"actions/checkout@v5": {}}
ctx := &PinContext{Warnings: make(map[string]bool, len(existing))}
for warning := range existing {
ctx.Warnings[warning] = true
}

initWarnings(ctx)

require.NotNil(t, ctx.Warnings, "Expected warnings map to remain initialized")
assert.Equal(t, existing, ctx.Warnings, "Expected existing warnings entries to be preserved")
assert.Len(t, ctx.Warnings, len(existing), "Expected existing warnings entries to be preserved")
for warning := range existing {
assert.True(t, ctx.Warnings[warning], "Expected warning %q to be preserved", warning)
}
})
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/cli/add_interactive_schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,15 @@ func TestBuildScheduleOptions(t *testing.T) {
t.Run("includes all standard frequencies", func(t *testing.T) {
opts := buildScheduleOptions("daily", "daily")
require.NotEmpty(t, opts, "options should not be empty")
values := make(map[string]bool)
values := make(map[string]struct{})
for _, o := range opts {
values[o.Value] = true
values[o.Value] = struct{}{}
}
assert.True(t, values["hourly"], "hourly should be included")
assert.True(t, values["3-hourly"], "3-hourly should be included")
assert.True(t, values["daily"], "daily should be included")
assert.True(t, values["weekly"], "weekly should be included")
assert.True(t, values["monthly"], "monthly should be included")
assert.Contains(t, values, "hourly", "hourly should be included")
assert.Contains(t, values, "3-hourly", "3-hourly should be included")
assert.Contains(t, values, "daily", "daily should be included")
assert.Contains(t, values, "weekly", "weekly should be included")
assert.Contains(t, values, "monthly", "monthly should be included")
})

t.Run("custom schedule has no duplicate custom option", func(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/copilot_events_jsonl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ func TestParseEventsJSONLFile(t *testing.T) {
}

// Verify each expected tool name appears in ToolCalls
toolNames := make(map[string]bool)
toolNames := make(map[string]struct{})
for _, tc := range metrics.ToolCalls {
toolNames[tc.Name] = true
toolNames[tc.Name] = struct{}{}
}
for _, expectedTool := range tt.wantToolCalls {
assert.True(t, toolNames[expectedTool], "tool %q should be in ToolCalls", expectedTool)
assert.Contains(t, toolNames, expectedTool, "tool %q should be in ToolCalls", expectedTool)
}
})
}
Expand Down
49 changes: 32 additions & 17 deletions pkg/cli/dependency_graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ description: Standalone workflow
}

// Check that both importers are in the list
affectedMap := make(map[string]bool)
affectedMap := make(map[string]struct{})
for _, w := range affected {
affectedMap[w] = true
affectedMap[w] = struct{}{}
}

if !affectedMap[topWorkflow1] {
if _, ok := affectedMap[topWorkflow1]; !ok {
t.Errorf("GetAffectedWorkflows() should include %s", topWorkflow1)
}
if !affectedMap[topWorkflow2] {
if _, ok := affectedMap[topWorkflow2]; !ok {
t.Errorf("GetAffectedWorkflows() should include %s", topWorkflow2)
}
})
Expand Down Expand Up @@ -353,13 +353,13 @@ imports:
}

// Verify all three workflows are in the affected list
affectedMap := make(map[string]bool)
affectedMap := make(map[string]struct{})
for _, w := range affected {
affectedMap[w] = true
affectedMap[w] = struct{}{}
}

for i, wf := range workflows {
if !affectedMap[wf] {
if _, ok := affectedMap[wf]; !ok {
t.Errorf("GetAffectedWorkflows() should include workflow%d.md", i)
}
}
Expand Down Expand Up @@ -662,12 +662,18 @@ imports:
t.Errorf("GetAffectedWorkflows(C) returned %d workflows, want 3", len(affected))
}

affectedMap := make(map[string]bool)
affectedMap := make(map[string]struct{})
for _, w := range affected {
affectedMap[w] = true
affectedMap[w] = struct{}{}
}

if !affectedMap[top1] || !affectedMap[top2] || !affectedMap[top3] {
if _, ok := affectedMap[top1]; !ok {
t.Errorf("GetAffectedWorkflows(C) should include top1, top2, and top3")
}
if _, ok := affectedMap[top2]; !ok {
t.Errorf("GetAffectedWorkflows(C) should include top1, top2, and top3")
}
if _, ok := affectedMap[top3]; !ok {
t.Errorf("GetAffectedWorkflows(C) should include top1, top2, and top3")
}
})
Expand All @@ -680,12 +686,18 @@ imports:
t.Errorf("GetAffectedWorkflows(B) returned %d workflows, want 3", len(affected))
}

affectedMap := make(map[string]bool)
affectedMap := make(map[string]struct{})
for _, w := range affected {
affectedMap[w] = true
affectedMap[w] = struct{}{}
}

if !affectedMap[top1] || !affectedMap[top2] || !affectedMap[top3] {
if _, ok := affectedMap[top1]; !ok {
t.Errorf("GetAffectedWorkflows(B) should include top1, top2, and top3")
}
if _, ok := affectedMap[top2]; !ok {
t.Errorf("GetAffectedWorkflows(B) should include top1, top2, and top3")
}
if _, ok := affectedMap[top3]; !ok {
t.Errorf("GetAffectedWorkflows(B) should include top1, top2, and top3")
}
})
Expand All @@ -698,16 +710,19 @@ imports:
t.Errorf("GetAffectedWorkflows(A) returned %d workflows, want 2", len(affected))
}

affectedMap := make(map[string]bool)
affectedMap := make(map[string]struct{})
for _, w := range affected {
affectedMap[w] = true
affectedMap[w] = struct{}{}
}

if !affectedMap[top1] || !affectedMap[top2] {
if _, ok := affectedMap[top1]; !ok {
t.Errorf("GetAffectedWorkflows(A) should include top1 and top2")
}
if _, ok := affectedMap[top2]; !ok {
t.Errorf("GetAffectedWorkflows(A) should include top1 and top2")
}

if affectedMap[top3] {
if _, ok := affectedMap[top3]; ok {
t.Errorf("GetAffectedWorkflows(A) should NOT include top3")
}
})
Expand Down
12 changes: 12 additions & 0 deletions pkg/cli/engine_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ func getMissingRequiredSecrets(requirements []SecretRequirement, existingSecrets
return missing
}

func stringSetToBoolMap(set map[string]struct{}) map[string]bool {
if len(set) == 0 {
return map[string]bool{}
}

result := make(map[string]bool, len(set))
for item := range set {
result[item] = true
}
return result
}

// ctx returns the context from the config, defaulting to background if nil
func (c EngineSecretConfig) ctx() context.Context {
if c.Ctx != nil {
Expand Down
Loading
Loading