(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestParseRemoteOrigin(t *testing.T) { |
| 20 | tests := []struct { |
| 21 | name string |
| 22 | spec string |
| 23 | expected *remoteImportOrigin |
| 24 | }{ |
| 25 | { |
| 26 | name: "basic workflowspec with ref", |
| 27 | spec: "elastic/ai-github-actions/gh-agent-workflows/mention-in-pr/rwxp.md@main", |
| 28 | expected: &remoteImportOrigin{ |
| 29 | Owner: "elastic", |
| 30 | Repo: "ai-github-actions", |
| 31 | Ref: "main", |
| 32 | BasePath: "gh-agent-workflows/mention-in-pr", |
| 33 | }, |
| 34 | }, |
| 35 | { |
| 36 | name: "workflowspec with SHA ref", |
| 37 | spec: "elastic/ai-github-actions/gh-agent-workflows/mention-in-pr/rwxp.md@160c33700227b5472dc3a08aeea1e774389a1a84", |
| 38 | expected: &remoteImportOrigin{ |
| 39 | Owner: "elastic", |
| 40 | Repo: "ai-github-actions", |
| 41 | Ref: "160c33700227b5472dc3a08aeea1e774389a1a84", |
| 42 | BasePath: "gh-agent-workflows/mention-in-pr", |
| 43 | }, |
| 44 | }, |
| 45 | { |
| 46 | name: "workflowspec without ref defaults to main", |
| 47 | spec: "elastic/ai-github-actions/gh-agent-workflows/file.md", |
| 48 | expected: &remoteImportOrigin{ |
| 49 | Owner: "elastic", |
| 50 | Repo: "ai-github-actions", |
| 51 | Ref: "main", |
| 52 | BasePath: "gh-agent-workflows", |
| 53 | }, |
| 54 | }, |
| 55 | { |
| 56 | name: "workflowspec with section reference", |
| 57 | spec: "owner/repo/path/file.md@v1.0#SectionName", |
| 58 | expected: &remoteImportOrigin{ |
| 59 | Owner: "owner", |
| 60 | Repo: "repo", |
| 61 | Ref: "v1.0", |
| 62 | BasePath: "path", |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | name: "workflowspec under .github/workflows", |
| 67 | spec: "owner/repo/.github/workflows/test.md@main", |
| 68 | expected: &remoteImportOrigin{ |
| 69 | Owner: "owner", |
| 70 | Repo: "repo", |
| 71 | Ref: "main", |
| 72 | BasePath: ".github/workflows", |
| 73 | }, |
| 74 | }, |
| 75 | { |
| 76 | name: "workflowspec with deep path", |
nothing calls this directly
no test coverage detected