| 26 | ) |
| 27 | |
| 28 | func TestNewCmdSet(t *testing.T) { |
| 29 | tests := []struct { |
| 30 | name string |
| 31 | args string |
| 32 | wants SetOptions |
| 33 | stdinTTY bool |
| 34 | wantsErr bool |
| 35 | wantsErrMessage string |
| 36 | }{ |
| 37 | { |
| 38 | name: "invalid visibility", |
| 39 | args: "cool_secret --org coolOrg -v mistyVeil", |
| 40 | wantsErr: true, |
| 41 | }, |
| 42 | { |
| 43 | name: "when visibility is selected, requires indication of repos", |
| 44 | args: "cool_secret --org coolOrg -v selected", |
| 45 | wantsErr: true, |
| 46 | wantsErrMessage: "`--repos` or `--no-repos-selected` required with `--visibility=selected`", |
| 47 | }, |
| 48 | { |
| 49 | name: "visibilities other than selected do not accept --repos", |
| 50 | args: "cool_secret --org coolOrg -v private -r coolRepo", |
| 51 | wantsErr: true, |
| 52 | wantsErrMessage: "`--repos` is only supported with `--visibility=selected`", |
| 53 | }, |
| 54 | { |
| 55 | name: "visibilities other than selected do not accept --no-repos-selected", |
| 56 | args: "cool_secret --org coolOrg -v private --no-repos-selected", |
| 57 | wantsErr: true, |
| 58 | wantsErrMessage: "`--no-repos-selected` is only supported with `--visibility=selected`", |
| 59 | }, |
| 60 | { |
| 61 | name: "--repos and --no-repos-selected are mutually exclusive", |
| 62 | args: `--repos coolRepo --no-repos-selected cool_secret`, |
| 63 | wantsErr: true, |
| 64 | wantsErrMessage: "specify only one of `--repos` or `--no-repos-selected`", |
| 65 | }, |
| 66 | { |
| 67 | name: "secret name is required", |
| 68 | args: "", |
| 69 | wantsErr: true, |
| 70 | }, |
| 71 | { |
| 72 | name: "multiple positional arguments are not allowed", |
| 73 | args: "cool_secret good_secret", |
| 74 | wantsErr: true, |
| 75 | }, |
| 76 | { |
| 77 | name: "visibility is only allowed with --org", |
| 78 | args: "cool_secret -v all", |
| 79 | wantsErr: true, |
| 80 | }, |
| 81 | { |
| 82 | name: "providing --repos without --visibility implies selected visibility", |
| 83 | args: "cool_secret --body secret-body --org coolOrg --repos coolRepo", |
| 84 | wants: SetOptions{ |
| 85 | SecretName: "cool_secret", |