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

Function TestGetActionRef

pkg/cli/copilot_setup_test.go:1464–1510  ·  view source on GitHub ↗

TestGetActionRef tests the getActionRef helper with and without a resolver

(t *testing.T)

Source from the content-addressed store, hash-verified

1462
1463// TestGetActionRef tests the getActionRef helper with and without a resolver
1464func TestGetActionRef(t *testing.T) {
1465 tests := []struct {
1466 name string
1467 actionMode workflow.ActionMode
1468 version string
1469 resolver workflow.SHAResolver
1470 expectedRef string
1471 }{
1472 {
1473 name: "release mode without resolver uses version tag",
1474 actionMode: workflow.ActionModeRelease,
1475 version: "v1.2.3",
1476 resolver: nil,
1477 expectedRef: "@v1.2.3",
1478 },
1479 {
1480 name: "release mode with resolver uses SHA-pinned reference",
1481 actionMode: workflow.ActionModeRelease,
1482 version: "v1.2.3",
1483 resolver: &mockSHAResolver{sha: "abc1234567890123456789012345678901234567890"},
1484 expectedRef: "@abc1234567890123456789012345678901234567890 # v1.2.3",
1485 },
1486 {
1487 name: "release mode with failing resolver falls back to version tag",
1488 actionMode: workflow.ActionModeRelease,
1489 version: "v1.2.3",
1490 resolver: &mockSHAResolver{sha: "", err: errors.New("resolution failed")},
1491 expectedRef: "@v1.2.3",
1492 },
1493 {
1494 name: "dev mode uses @main",
1495 actionMode: workflow.ActionModeDev,
1496 version: "v1.2.3",
1497 resolver: nil,
1498 expectedRef: "@main",
1499 },
1500 }
1501
1502 for _, tt := range tests {
1503 t.Run(tt.name, func(t *testing.T) {
1504 ref := getActionRef(context.Background(), tt.actionMode, tt.version, tt.resolver)
1505 if ref != tt.expectedRef {
1506 t.Errorf("getActionRef(context.Background()) = %q, want %q", ref, tt.expectedRef)
1507 }
1508 })
1509 }
1510}

Callers

nothing calls this directly

Calls 4

getActionRefFunction · 0.85
BackgroundMethod · 0.80
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected