| 140 | } |
| 141 | |
| 142 | func TestFindLegacy(t *testing.T) { |
| 143 | tmpdir, err := os.MkdirTemp("", "gh-cli") |
| 144 | if err != nil { |
| 145 | t.Fatal(err) |
| 146 | } |
| 147 | |
| 148 | type args struct { |
| 149 | rootDir string |
| 150 | name string |
| 151 | } |
| 152 | tests := []struct { |
| 153 | name string |
| 154 | prepare []string |
| 155 | args args |
| 156 | want string |
| 157 | }{ |
| 158 | { |
| 159 | name: "Template in root", |
| 160 | prepare: []string{ |
| 161 | "README.md", |
| 162 | "issue_template.md", |
| 163 | "issue_template.txt", |
| 164 | "pull_request_template.md", |
| 165 | "docs/issue_template.md", |
| 166 | }, |
| 167 | args: args{ |
| 168 | rootDir: tmpdir, |
| 169 | name: "ISSUE_TEMPLATE", |
| 170 | }, |
| 171 | want: path.Join(tmpdir, "issue_template.md"), |
| 172 | }, |
| 173 | { |
| 174 | name: "No extension", |
| 175 | prepare: []string{ |
| 176 | "README.md", |
| 177 | "issue_template", |
| 178 | "docs/issue_template.md", |
| 179 | }, |
| 180 | args: args{ |
| 181 | rootDir: tmpdir, |
| 182 | name: "ISSUE_TEMPLATE", |
| 183 | }, |
| 184 | want: path.Join(tmpdir, "issue_template"), |
| 185 | }, |
| 186 | { |
| 187 | name: "Dash instead of underscore", |
| 188 | prepare: []string{ |
| 189 | "README.md", |
| 190 | "issue-template.txt", |
| 191 | "docs/issue_template.md", |
| 192 | }, |
| 193 | args: args{ |
| 194 | rootDir: tmpdir, |
| 195 | name: "ISSUE_TEMPLATE", |
| 196 | }, |
| 197 | want: path.Join(tmpdir, "issue-template.txt"), |
| 198 | }, |
| 199 | { |