TestFormatActionReference tests the formatActionReference helper function
(t *testing.T)
| 1193 | |
| 1194 | // TestFormatActionReference tests the formatActionReference helper function |
| 1195 | func TestFormatActionReference(t *testing.T) { |
| 1196 | tests := []struct { |
| 1197 | name string |
| 1198 | repo string |
| 1199 | sha string |
| 1200 | version string |
| 1201 | expected string |
| 1202 | }{ |
| 1203 | { |
| 1204 | name: "standard action reference", |
| 1205 | repo: "actions/checkout", |
| 1206 | sha: "abc1234567890123456789012345678901234567", |
| 1207 | version: "v4.1.0", |
| 1208 | expected: "actions/checkout@abc1234567890123456789012345678901234567 # v4.1.0", |
| 1209 | }, |
| 1210 | { |
| 1211 | name: "action with simple version", |
| 1212 | repo: "actions/setup-node", |
| 1213 | sha: "def9876543210987654321098765432109876543", |
| 1214 | version: "v20", |
| 1215 | expected: "actions/setup-node@def9876543210987654321098765432109876543 # v20", |
| 1216 | }, |
| 1217 | { |
| 1218 | name: "action with short repo name", |
| 1219 | repo: "x/y", |
| 1220 | sha: "1234567890123456789012345678901234567890", |
| 1221 | version: "v1", |
| 1222 | expected: "x/y@1234567890123456789012345678901234567890 # v1", |
| 1223 | }, |
| 1224 | { |
| 1225 | name: "action with nested repo path", |
| 1226 | repo: "github/codeql-action/upload-sarif", |
| 1227 | sha: "abcdef1234567890abcdef1234567890abcdef12", |
| 1228 | version: "v3.27.9", |
| 1229 | expected: "github/codeql-action/upload-sarif@abcdef1234567890abcdef1234567890abcdef12 # v3.27.9", |
| 1230 | }, |
| 1231 | } |
| 1232 | |
| 1233 | for _, tt := range tests { |
| 1234 | t.Run(tt.name, func(t *testing.T) { |
| 1235 | result := formatActionReference(tt.repo, tt.sha, tt.version) |
| 1236 | if result != tt.expected { |
| 1237 | t.Errorf("formatActionReference(%q, %q, %q) = %q, want %q", |
| 1238 | tt.repo, tt.sha, tt.version, result, tt.expected) |
| 1239 | } |
| 1240 | }) |
| 1241 | } |
| 1242 | } |
| 1243 | |
| 1244 | // TestFormatActionCacheKey tests the formatActionCacheKey helper function |
| 1245 | func TestFormatActionCacheKey(t *testing.T) { |
nothing calls this directly
no test coverage detected