(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestFetchLocalWorkflow(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | content string |
| 28 | expectError bool |
| 29 | }{ |
| 30 | { |
| 31 | name: "valid workflow file", |
| 32 | content: `--- |
| 33 | name: Test Workflow |
| 34 | on: workflow_dispatch |
| 35 | --- |
| 36 | |
| 37 | # Test Workflow |
| 38 | |
| 39 | This is a test. |
| 40 | `, |
| 41 | expectError: false, |
| 42 | }, |
| 43 | { |
| 44 | name: "empty file", |
| 45 | content: "", |
| 46 | expectError: false, |
| 47 | }, |
| 48 | { |
| 49 | name: "minimal content", |
| 50 | content: "# Hello", |
| 51 | expectError: false, |
| 52 | }, |
| 53 | } |
| 54 | |
| 55 | for _, tt := range tests { |
| 56 | t.Run(tt.name, func(t *testing.T) { |
| 57 | // Create a temporary file |
| 58 | tempDir := t.TempDir() |
| 59 | tempFile := filepath.Join(tempDir, "test-workflow.md") |
| 60 | err := os.WriteFile(tempFile, []byte(tt.content), 0644) |
| 61 | require.NoError(t, err, "should create temp file") |
| 62 | |
| 63 | spec := &WorkflowSpec{ |
| 64 | WorkflowPath: tempFile, |
| 65 | WorkflowName: "test-workflow", |
| 66 | } |
| 67 | |
| 68 | result, err := fetchLocalWorkflow(spec, false) |
| 69 | |
| 70 | if tt.expectError { |
| 71 | assert.Error(t, err, "expected error") |
| 72 | } else { |
| 73 | require.NoError(t, err, "should not error") |
| 74 | assert.Equal(t, []byte(tt.content), result.Content, "content should match") |
| 75 | assert.True(t, result.IsLocal, "should be marked as local") |
| 76 | assert.Empty(t, result.CommitSHA, "local workflows should not have commit SHA") |
| 77 | assert.Equal(t, tempFile, result.SourcePath, "source path should match") |
| 78 | } |
| 79 | }) |
| 80 | } |
| 81 | } |
nothing calls this directly
no test coverage detected