| 22 | ) |
| 23 | |
| 24 | func TestNewCmdSet(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | cli string |
| 28 | wants SetOptions |
| 29 | stdinTTY bool |
| 30 | wantsErr bool |
| 31 | }{ |
| 32 | { |
| 33 | name: "invalid visibility type", |
| 34 | cli: "cool_variable --org coolOrg -v'mistyVeil'", |
| 35 | wantsErr: true, |
| 36 | }, |
| 37 | { |
| 38 | name: "selected visibility with no repos selected", |
| 39 | cli: "cool_variable --org coolOrg -v'selected'", |
| 40 | wantsErr: true, |
| 41 | }, |
| 42 | { |
| 43 | name: "private visibility with repos selected", |
| 44 | cli: "cool_variable --org coolOrg -v'private' -rcoolRepo", |
| 45 | wantsErr: true, |
| 46 | }, |
| 47 | { |
| 48 | name: "no name specified", |
| 49 | cli: "", |
| 50 | wantsErr: true, |
| 51 | }, |
| 52 | { |
| 53 | name: "multiple names specified", |
| 54 | cli: "cool_variable good_variable", |
| 55 | wantsErr: true, |
| 56 | }, |
| 57 | { |
| 58 | name: "visibility without org", |
| 59 | cli: "cool_variable -vall", |
| 60 | wantsErr: true, |
| 61 | }, |
| 62 | { |
| 63 | name: "repos without explicit visibility", |
| 64 | cli: "cool_variable -bs --org coolOrg -rcoolRepo", |
| 65 | wants: SetOptions{ |
| 66 | VariableName: "cool_variable", |
| 67 | Visibility: shared.Selected, |
| 68 | RepositoryNames: []string{"coolRepo"}, |
| 69 | Body: "s", |
| 70 | OrgName: "coolOrg", |
| 71 | }, |
| 72 | }, |
| 73 | { |
| 74 | name: "org with explicit visibility and selected repo", |
| 75 | cli: "-ocoolOrg -bs -vselected -rcoolRepo cool_variable", |
| 76 | wants: SetOptions{ |
| 77 | VariableName: "cool_variable", |
| 78 | Visibility: shared.Selected, |
| 79 | RepositoryNames: []string{"coolRepo"}, |
| 80 | Body: "s", |
| 81 | OrgName: "coolOrg", |