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