(t *testing.T)
| 304 | } |
| 305 | |
| 306 | func TestHasWorkflowCallTrigger(t *testing.T) { |
| 307 | tests := []struct { |
| 308 | name string |
| 309 | onSection string |
| 310 | expected bool |
| 311 | }{ |
| 312 | { |
| 313 | name: "workflow_call present in map format", |
| 314 | onSection: `"on": |
| 315 | workflow_call:`, |
| 316 | expected: true, |
| 317 | }, |
| 318 | { |
| 319 | name: "workflow_call present with inputs", |
| 320 | onSection: `"on": |
| 321 | workflow_call: |
| 322 | inputs: |
| 323 | issue_number: |
| 324 | required: true |
| 325 | type: number`, |
| 326 | expected: true, |
| 327 | }, |
| 328 | { |
| 329 | name: "workflow_call absent - push and workflow_dispatch only", |
| 330 | onSection: `"on": |
| 331 | push: |
| 332 | workflow_dispatch:`, |
| 333 | expected: false, |
| 334 | }, |
| 335 | { |
| 336 | name: "workflow_call with other triggers - issue_comment and workflow_call", |
| 337 | onSection: `"on": |
| 338 | issue_comment: |
| 339 | types: [created] |
| 340 | workflow_call:`, |
| 341 | expected: true, |
| 342 | }, |
| 343 | { |
| 344 | name: "empty string", |
| 345 | onSection: "", |
| 346 | expected: false, |
| 347 | }, |
| 348 | { |
| 349 | name: "workflow_dispatch only - not workflow_call", |
| 350 | onSection: `"on": |
| 351 | workflow_dispatch:`, |
| 352 | expected: false, |
| 353 | }, |
| 354 | } |
| 355 | |
| 356 | for _, tt := range tests { |
| 357 | t.Run(tt.name, func(t *testing.T) { |
| 358 | result := hasWorkflowCallTrigger(tt.onSection) |
| 359 | assert.Equal(t, tt.expected, result, "hasWorkflowCallTrigger() result mismatch for %q", tt.name) |
| 360 | }) |
| 361 | } |
| 362 | } |
| 363 |
nothing calls this directly
no test coverage detected