| 8 | ) |
| 9 | |
| 10 | func TestFindNonLegacy(t *testing.T) { |
| 11 | tmpdir, err := os.MkdirTemp("", "gh-cli") |
| 12 | if err != nil { |
| 13 | t.Fatal(err) |
| 14 | } |
| 15 | |
| 16 | type args struct { |
| 17 | rootDir string |
| 18 | name string |
| 19 | } |
| 20 | tests := []struct { |
| 21 | name string |
| 22 | prepare []string |
| 23 | args args |
| 24 | want []string |
| 25 | }{ |
| 26 | { |
| 27 | name: "Legacy templates ignored", |
| 28 | prepare: []string{ |
| 29 | "README.md", |
| 30 | "ISSUE_TEMPLATE", |
| 31 | "issue_template.md", |
| 32 | "issue_template.txt", |
| 33 | "pull_request_template.md", |
| 34 | ".github/issue_template.md", |
| 35 | "docs/issue_template.md", |
| 36 | }, |
| 37 | args: args{ |
| 38 | rootDir: tmpdir, |
| 39 | name: "ISSUE_TEMPLATE", |
| 40 | }, |
| 41 | want: []string{}, |
| 42 | }, |
| 43 | { |
| 44 | name: "Template folder in .github takes precedence", |
| 45 | prepare: []string{ |
| 46 | "ISSUE_TEMPLATE.md", |
| 47 | "docs/ISSUE_TEMPLATE/abc.md", |
| 48 | "ISSUE_TEMPLATE/abc.md", |
| 49 | ".github/ISSUE_TEMPLATE/abc.md", |
| 50 | }, |
| 51 | args: args{ |
| 52 | rootDir: tmpdir, |
| 53 | name: "ISSUE_TEMPLATE", |
| 54 | }, |
| 55 | want: []string{ |
| 56 | path.Join(tmpdir, ".github/ISSUE_TEMPLATE/abc.md"), |
| 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | name: "Template folder in root", |
| 61 | prepare: []string{ |
| 62 | "ISSUE_TEMPLATE.md", |
| 63 | "docs/ISSUE_TEMPLATE/abc.md", |
| 64 | "ISSUE_TEMPLATE/abc.md", |
| 65 | }, |
| 66 | args: args{ |
| 67 | rootDir: tmpdir, |