(t *testing.T)
| 326 | } |
| 327 | |
| 328 | func TestIsCompositeAction(t *testing.T) { |
| 329 | tests := []struct { |
| 330 | name string |
| 331 | actionYmlContent string |
| 332 | expectComposite bool |
| 333 | expectError bool |
| 334 | }{ |
| 335 | { |
| 336 | name: "composite action with single quotes", |
| 337 | actionYmlContent: `name: Test Action |
| 338 | description: A test action |
| 339 | runs: |
| 340 | using: 'composite' |
| 341 | steps: |
| 342 | - run: echo "test"`, |
| 343 | expectComposite: true, |
| 344 | expectError: false, |
| 345 | }, |
| 346 | { |
| 347 | name: "composite action with double quotes", |
| 348 | actionYmlContent: `name: Test Action |
| 349 | description: A test action |
| 350 | runs: |
| 351 | using: "composite" |
| 352 | steps: |
| 353 | - run: echo "test"`, |
| 354 | expectComposite: true, |
| 355 | expectError: false, |
| 356 | }, |
| 357 | { |
| 358 | name: "node20 action", |
| 359 | actionYmlContent: `name: Test Action |
| 360 | description: A test action |
| 361 | runs: |
| 362 | using: 'node20' |
| 363 | main: 'index.js'`, |
| 364 | expectComposite: false, |
| 365 | expectError: false, |
| 366 | }, |
| 367 | { |
| 368 | name: "missing action.yml", |
| 369 | expectComposite: false, |
| 370 | expectError: true, |
| 371 | }, |
| 372 | } |
| 373 | |
| 374 | for _, tt := range tests { |
| 375 | t.Run(tt.name, func(t *testing.T) { |
| 376 | tmpDir := t.TempDir() |
| 377 | actionPath := filepath.Join(tmpDir, "test-action") |
| 378 | err := os.MkdirAll(actionPath, 0755) |
| 379 | require.NoError(t, err, "Failed to create action directory") |
| 380 | |
| 381 | if tt.actionYmlContent != "" { |
| 382 | ymlPath := filepath.Join(actionPath, "action.yml") |
| 383 | err = os.WriteFile(ymlPath, []byte(tt.actionYmlContent), 0644) |
| 384 | require.NoError(t, err, "Failed to write action.yml") |
| 385 | } |
nothing calls this directly
no test coverage detected