(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestGetWorkflowStatuses(t *testing.T) { |
| 15 | tests := []struct { |
| 16 | name string |
| 17 | pattern string |
| 18 | repoOverride string |
| 19 | verbose bool |
| 20 | // We can't easily test the actual results without mocking gh CLI, |
| 21 | // so we just verify the function doesn't panic |
| 22 | }{ |
| 23 | { |
| 24 | name: "simple pattern", |
| 25 | pattern: "test-workflow", |
| 26 | repoOverride: "", |
| 27 | verbose: false, |
| 28 | }, |
| 29 | { |
| 30 | name: "with repo override", |
| 31 | pattern: "daily-status", |
| 32 | repoOverride: "owner/repo", |
| 33 | verbose: false, |
| 34 | }, |
| 35 | { |
| 36 | name: "verbose mode", |
| 37 | pattern: "workflow-name", |
| 38 | repoOverride: "owner/repo", |
| 39 | verbose: true, |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | for _, tt := range tests { |
| 44 | t.Run(tt.name, func(t *testing.T) { |
| 45 | // This function calls gh CLI, so it will likely error in tests |
| 46 | // We just verify it doesn't panic |
| 47 | statuses, err := findWorkflowsByFilenamePattern(tt.pattern, tt.repoOverride, tt.verbose) |
| 48 | |
| 49 | // Either succeeds or fails gracefully, but shouldn't panic |
| 50 | // Note: statuses may be nil even when err is nil (no workflows found) |
| 51 | if err != nil { |
| 52 | // Error is acceptable in test environment without gh CLI setup |
| 53 | require.Error(t, err, "Expected error without gh CLI") |
| 54 | } |
| 55 | // If no error and statuses exist, verify they have expected structure |
| 56 | if err == nil && statuses != nil { |
| 57 | for _, status := range statuses { |
| 58 | assert.NotEmpty(t, status.Workflow, "Workflow name should not be empty") |
| 59 | } |
| 60 | } |
| 61 | }) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestCheckStatusAndOfferRun_ContextCancelled(t *testing.T) { |
| 66 | ctx, cancel := context.WithCancel(t.Context()) |
nothing calls this directly
no test coverage detected