(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestNewCmdDelete(t *testing.T) { |
| 18 | tests := []struct { |
| 19 | name string |
| 20 | input string |
| 21 | tty bool |
| 22 | output DeleteOptions |
| 23 | wantErr bool |
| 24 | wantErrMsg string |
| 25 | wantStderr string |
| 26 | }{ |
| 27 | { |
| 28 | name: "confirm flag", |
| 29 | tty: true, |
| 30 | input: "OWNER/REPO --confirm", |
| 31 | output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true}, |
| 32 | }, |
| 33 | { |
| 34 | name: "yes flag", |
| 35 | tty: true, |
| 36 | input: "OWNER/REPO --yes", |
| 37 | output: DeleteOptions{RepoArg: "OWNER/REPO", Confirmed: true}, |
| 38 | }, |
| 39 | { |
| 40 | name: "no confirmation notty", |
| 41 | input: "OWNER/REPO", |
| 42 | output: DeleteOptions{RepoArg: "OWNER/REPO"}, |
| 43 | wantErr: true, |
| 44 | wantErrMsg: "--yes required when not running interactively", |
| 45 | }, |
| 46 | { |
| 47 | name: "base repo resolution", |
| 48 | input: "", |
| 49 | tty: true, |
| 50 | output: DeleteOptions{}, |
| 51 | }, |
| 52 | { |
| 53 | name: "yes flag ignored when no argument tty", |
| 54 | tty: true, |
| 55 | input: "--yes", |
| 56 | output: DeleteOptions{Confirmed: false}, // --yes should be ignored |
| 57 | wantErr: false, |
| 58 | wantStderr: "Warning: `--yes` is ignored since no repository was specified\n", |
| 59 | }, |
| 60 | { |
| 61 | name: "yes flag error when no argument notty", |
| 62 | input: "--yes", |
| 63 | wantErr: true, |
| 64 | wantErrMsg: "cannot non-interactively delete current repository. Please specify a repository or run interactively", |
| 65 | }, |
| 66 | { |
| 67 | name: "confirm flag error when no argument notty", |
| 68 | input: "--confirm", |
| 69 | wantErr: true, |
| 70 | wantErrMsg: "cannot non-interactively delete current repository. Please specify a repository or run interactively", |
| 71 | }, |
| 72 | { |
| 73 | name: "confirm flag also ignored when no argument tty", |
| 74 | tty: true, |
nothing calls this directly
no test coverage detected