TestUpgradeSetupCliVersionInContent tests the regex-based content upgrade helper.
(t *testing.T)
| 1043 | |
| 1044 | // TestUpgradeSetupCliVersionInContent tests the regex-based content upgrade helper. |
| 1045 | func 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" |
| 1060 | on: workflow_dispatch |
| 1061 | jobs: |
| 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" |
| 1095 | on: workflow_dispatch |
| 1096 | jobs: |
| 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: |
nothing calls this directly
no test coverage detected