(t *testing.T)
| 37 | ) |
| 38 | |
| 39 | func TestNewCmdCreate(t *testing.T) { |
| 40 | tmpFile := filepath.Join(t.TempDir(), "my-body.md") |
| 41 | err := os.WriteFile(tmpFile, []byte("a body from file"), 0600) |
| 42 | require.NoError(t, err) |
| 43 | |
| 44 | tmpImage := filepath.Join(t.TempDir(), "shot.png") |
| 45 | require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600)) |
| 46 | |
| 47 | tests := []struct { |
| 48 | name string |
| 49 | tty bool |
| 50 | stdin string |
| 51 | cli string |
| 52 | config string |
| 53 | wantsErr bool |
| 54 | wantsErrMsg string |
| 55 | // wantErrIsNotExist covers an error whose text the operating system |
| 56 | // words differently, so the assertion cannot be on the message. |
| 57 | wantErrIsNotExist bool |
| 58 | wantAssetPaths []string |
| 59 | wantsOpts CreateOptions |
| 60 | }{ |
| 61 | { |
| 62 | name: "empty non-tty", |
| 63 | tty: false, |
| 64 | cli: "", |
| 65 | wantsErr: true, |
| 66 | }, |
| 67 | { |
| 68 | name: "only title non-tty", |
| 69 | tty: false, |
| 70 | cli: "--title mytitle", |
| 71 | wantsErr: true, |
| 72 | }, |
| 73 | { |
| 74 | name: "minimum non-tty", |
| 75 | tty: false, |
| 76 | cli: "--title mytitle --body ''", |
| 77 | wantsErr: false, |
| 78 | wantsOpts: CreateOptions{ |
| 79 | Title: "mytitle", |
| 80 | TitleProvided: true, |
| 81 | Body: "", |
| 82 | BodyProvided: true, |
| 83 | Autofill: false, |
| 84 | RecoverFile: "", |
| 85 | WebMode: false, |
| 86 | IsDraft: false, |
| 87 | BaseBranch: "", |
| 88 | HeadBranch: "", |
| 89 | MaintainerCanModify: true, |
| 90 | }, |
| 91 | }, |
| 92 | { |
| 93 | name: "empty tty", |
| 94 | tty: true, |
| 95 | cli: "", |
| 96 | wantsErr: false, |
nothing calls this directly
no test coverage detected