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

Function TestUpgradeSetupCliVersionInContent

pkg/cli/copilot_setup_test.go:1045–1246  ·  view source on GitHub ↗

TestUpgradeSetupCliVersionInContent tests the regex-based content upgrade helper.

(t *testing.T)

Source from the content-addressed store, hash-verified

1043
1044// TestUpgradeSetupCliVersionInContent tests the regex-based content upgrade helper.
1045func TestUpgradeSetupCliVersionInContent(t *testing.T) {
1046 t.Parallel()
1047
1048 tests := []struct {
1049 name string
1050 content string
1051 actionMode workflow.ActionMode
1052 version string
1053 resolver workflow.SHAResolver
1054 expectUpgrade bool
1055 validate func(*testing.T, string)
1056 }{
1057 {
1058 name: "upgrades version-tag ref",
1059 content: `name: "Copilot Setup Steps"
1060on: workflow_dispatch
1061jobs:
1062 copilot-setup-steps:
1063 runs-on: ubuntu-latest
1064 steps:
1065 - name: Checkout
1066 uses: actions/checkout@v4
1067 - name: Install gh-aw extension
1068 uses: github/gh-aw-actions/setup-cli@v1.0.0
1069 with:
1070 version: v1.0.0
1071`,
1072 actionMode: workflow.ActionModeRelease,
1073 version: "v2.0.0",
1074 resolver: nil,
1075 expectUpgrade: true,
1076 validate: func(t *testing.T, got string) {
1077 if !strings.Contains(got, "uses: github/gh-aw-actions/setup-cli@v2.0.0") {
1078 t.Errorf("Expected updated uses: line, got:\n%s", got)
1079 }
1080 if !strings.Contains(got, "version: v2.0.0") {
1081 t.Errorf("Expected updated version: parameter, got:\n%s", got)
1082 }
1083 if strings.Contains(got, "v1.0.0") {
1084 t.Errorf("Old version v1.0.0 should be gone, got:\n%s", got)
1085 }
1086 // File structure must be preserved (comment line, on: key, etc.)
1087 if !strings.Contains(got, "on: workflow_dispatch") {
1088 t.Errorf("Expected on: field to be preserved, got:\n%s", got)
1089 }
1090 },
1091 },
1092 {
1093 name: "upgrades SHA-pinned ref and produces unquoted uses: value",
1094 content: `name: "Copilot Setup Steps"
1095on: workflow_dispatch
1096jobs:
1097 copilot-setup-steps:
1098 runs-on: ubuntu-latest
1099 steps:
1100 - name: Install gh-aw extension
1101 uses: github/gh-aw-actions/setup-cli@v1.0.0
1102 with:

Callers

nothing calls this directly

Calls 5

BackgroundMethod · 0.80
validateMethod · 0.80
ErrorfMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected