(t *testing.T)
| 31 | ) |
| 32 | |
| 33 | func TestNewCmdCreate(t *testing.T) { |
| 34 | tmpFile := filepath.Join(t.TempDir(), "my-body.md") |
| 35 | err := os.WriteFile(tmpFile, []byte("a body from file"), 0600) |
| 36 | require.NoError(t, err) |
| 37 | |
| 38 | tests := []struct { |
| 39 | name string |
| 40 | tty bool |
| 41 | stdin string |
| 42 | cli string |
| 43 | config string |
| 44 | wantsErr bool |
| 45 | wantsOpts CreateOptions |
| 46 | }{ |
| 47 | { |
| 48 | name: "empty non-tty", |
| 49 | tty: false, |
| 50 | cli: "", |
| 51 | wantsErr: true, |
| 52 | }, |
| 53 | { |
| 54 | name: "only title non-tty", |
| 55 | tty: false, |
| 56 | cli: "--title mytitle", |
| 57 | wantsErr: true, |
| 58 | }, |
| 59 | { |
| 60 | name: "minimum non-tty", |
| 61 | tty: false, |
| 62 | cli: "--title mytitle --body ''", |
| 63 | wantsErr: false, |
| 64 | wantsOpts: CreateOptions{ |
| 65 | Title: "mytitle", |
| 66 | TitleProvided: true, |
| 67 | Body: "", |
| 68 | BodyProvided: true, |
| 69 | Autofill: false, |
| 70 | RecoverFile: "", |
| 71 | WebMode: false, |
| 72 | IsDraft: false, |
| 73 | BaseBranch: "", |
| 74 | HeadBranch: "", |
| 75 | MaintainerCanModify: true, |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | name: "empty tty", |
| 80 | tty: true, |
| 81 | cli: "", |
| 82 | wantsErr: false, |
| 83 | wantsOpts: CreateOptions{ |
| 84 | Title: "", |
| 85 | TitleProvided: false, |
| 86 | Body: "", |
| 87 | BodyProvided: false, |
| 88 | Autofill: false, |
| 89 | RecoverFile: "", |
| 90 | WebMode: false, |
nothing calls this directly
no test coverage detected