(t *testing.T)
| 381 | } |
| 382 | |
| 383 | func TestExtractContents(t *testing.T) { |
| 384 | tmpfile, err := os.CreateTemp(t.TempDir(), "gh-cli") |
| 385 | if err != nil { |
| 386 | t.Fatal(err) |
| 387 | } |
| 388 | defer tmpfile.Close() |
| 389 | |
| 390 | type args struct { |
| 391 | filePath string |
| 392 | } |
| 393 | tests := []struct { |
| 394 | name string |
| 395 | prepare string |
| 396 | args args |
| 397 | want string |
| 398 | }{ |
| 399 | { |
| 400 | name: "Has front-matter", |
| 401 | prepare: `--- |
| 402 | name: Bug Report |
| 403 | --- |
| 404 | |
| 405 | |
| 406 | Template contents |
| 407 | --- |
| 408 | More of template |
| 409 | `, |
| 410 | args: args{ |
| 411 | filePath: tmpfile.Name(), |
| 412 | }, |
| 413 | want: `Template contents |
| 414 | --- |
| 415 | More of template |
| 416 | `, |
| 417 | }, |
| 418 | { |
| 419 | name: "No front-matter", |
| 420 | prepare: `Template contents |
| 421 | --- |
| 422 | More of template |
| 423 | --- |
| 424 | Even more |
| 425 | `, |
| 426 | args: args{ |
| 427 | filePath: tmpfile.Name(), |
| 428 | }, |
| 429 | want: `Template contents |
| 430 | --- |
| 431 | More of template |
| 432 | --- |
| 433 | Even more |
| 434 | `, |
| 435 | }, |
| 436 | } |
| 437 | for _, tt := range tests { |
| 438 | t.Run(tt.name, func(t *testing.T) { |
| 439 | _ = os.WriteFile(tmpfile.Name(), []byte(tt.prepare), 0600) |
| 440 | if got := ExtractContents(tt.args.filePath); string(got) != tt.want { |
nothing calls this directly
no test coverage detected