(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestFormatImportError(t *testing.T) { |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | err *parser.ImportError |
| 17 | yamlContent string |
| 18 | wantContain []string |
| 19 | }{ |
| 20 | { |
| 21 | name: "file not found error", |
| 22 | err: &parser.ImportError{ |
| 23 | ImportPath: "missing.md", |
| 24 | FilePath: "test.md", |
| 25 | Line: 3, |
| 26 | Column: 3, |
| 27 | Cause: errors.New("file not found: /path/to/missing.md"), |
| 28 | }, |
| 29 | yamlContent: `--- |
| 30 | on: push |
| 31 | imports: |
| 32 | - missing.md |
| 33 | ---`, |
| 34 | wantContain: []string{ |
| 35 | "test.md:3:3:", |
| 36 | "error:", |
| 37 | "import file not found", |
| 38 | "imports:", |
| 39 | "hint:", |
| 40 | "missing.md", |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "download failed error", |
| 45 | err: &parser.ImportError{ |
| 46 | ImportPath: "owner/repo/file.md@main", |
| 47 | FilePath: "workflow.md", |
| 48 | Line: 4, |
| 49 | Column: 5, |
| 50 | Cause: errors.New("failed to download include from owner/repo/file.md@main: network error"), |
| 51 | }, |
| 52 | yamlContent: `--- |
| 53 | on: issues |
| 54 | imports: |
| 55 | - owner/repo/file.md@main |
| 56 | ---`, |
| 57 | wantContain: []string{ |
| 58 | "workflow.md:4:5:", |
| 59 | "error:", |
| 60 | "failed to download import file", |
| 61 | "owner/repo/file.md@main", |
| 62 | "hint:", |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | name: "ref resolution error", |
| 67 | err: &parser.ImportError{ |
| 68 | ImportPath: "owner/repo/file.md@v0.0.0-bad", |
| 69 | FilePath: "test.md", |
| 70 | Line: 3, |
nothing calls this directly
no test coverage detected