From 173c4ba2e647f1f305aa82fd81e0c2a33a7acdf5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:31:12 +0000 Subject: [PATCH] Fix failing spec tests and lint assertions Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d6322209-392d-4ee4-933d-157e178239a5 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/actionpins/spec_test.go | 17 ++++++++++------- pkg/cli/spec_test.go | 11 +++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pkg/actionpins/spec_test.go b/pkg/actionpins/spec_test.go index a40468863a2..252531c752e 100644 --- a/pkg/actionpins/spec_test.go +++ b/pkg/actionpins/spec_test.go @@ -256,26 +256,29 @@ func TestSpec_Types_ActionPinsData(t *testing.T) { assert.Equal(t, "actions/checkout", entry.Repo, "entry Repo should match") } -// TestSpec_ThreadSafety_ConcurrentGetActionPins validates that concurrent calls to GetActionPins +// TestSpec_ThreadSafety_ConcurrentGetActionPinsByRepo validates that concurrent calls to GetActionPinsByRepo // are safe after initialization (sync.Once guarantee from the spec). -func TestSpec_ThreadSafety_ConcurrentGetActionPins(t *testing.T) { +func TestSpec_ThreadSafety_ConcurrentGetActionPinsByRepo(t *testing.T) { const goroutines = 10 + const repo = "actions/checkout" results := make([][]actionpins.ActionPin, goroutines) done := make(chan int, goroutines) - for i := 0; i < goroutines; i++ { + for i := range goroutines { go func(idx int) { - results[idx] = actionpins.GetActionPins() + results[idx] = actionpins.GetActionPinsByRepo(repo) done <- idx }(i) } - for i := 0; i < goroutines; i++ { + for range goroutines { <-done } for i := 1; i < goroutines; i++ { - assert.Equal(t, len(results[0]), len(results[i]), - "concurrent GetActionPins should return same number of pins (goroutine %d vs 0)", i) + assert.NotEmpty(t, results[i], "concurrent GetActionPinsByRepo should return pins for known repo") + assert.Len(t, results[i], len(results[0]), + "concurrent GetActionPinsByRepo should return same number of pins (goroutine %d vs 0)", i) } + assert.NotEmpty(t, results[0], "concurrent GetActionPinsByRepo should return pins for known repo") } diff --git a/pkg/cli/spec_test.go b/pkg/cli/spec_test.go index 62fc2493721..cfc4580b265 100644 --- a/pkg/cli/spec_test.go +++ b/pkg/cli/spec_test.go @@ -851,11 +851,11 @@ func TestSpec_PublicAPI_IsRunningInCI(t *testing.T) { // TestSpec_Types_ShellType validates the documented ShellType string alias and its constants. // Spec: "bash", "zsh", "fish", "powershell", "unknown" func TestSpec_Types_ShellType(t *testing.T) { - assert.Equal(t, ShellType("bash"), ShellBash, "ShellBash constant should be \"bash\"") - assert.Equal(t, ShellType("zsh"), ShellZsh, "ShellZsh constant should be \"zsh\"") - assert.Equal(t, ShellType("fish"), ShellFish, "ShellFish constant should be \"fish\"") - assert.Equal(t, ShellType("powershell"), ShellPowerShell, "ShellPowerShell constant should be \"powershell\"") - assert.Equal(t, ShellType("unknown"), ShellUnknown, "ShellUnknown constant should be \"unknown\"") + assert.Equal(t, ShellBash, ShellType("bash"), "ShellBash constant should be \"bash\"") + assert.Equal(t, ShellZsh, ShellType("zsh"), "ShellZsh constant should be \"zsh\"") + assert.Equal(t, ShellFish, ShellType("fish"), "ShellFish constant should be \"fish\"") + assert.Equal(t, ShellPowerShell, ShellType("powershell"), "ShellPowerShell constant should be \"powershell\"") + assert.Equal(t, ShellUnknown, ShellType("unknown"), "ShellUnknown constant should be \"unknown\"") } // TestSpec_PublicAPI_DetectShell validates DetectShell returns one of the documented ShellType values. @@ -1009,4 +1009,3 @@ func TestSpec_DesignDecision_StderrDiagnostics(t *testing.T) { names := ValidArtifactSetNames() assert.NotEmpty(t, names, "ValidArtifactSetNames returns data via return value, not stdout") } -