| 16 | ) |
| 17 | |
| 18 | func TestNewCmdLink(t *testing.T) { |
| 19 | tests := []struct { |
| 20 | name string |
| 21 | cli string |
| 22 | wants linkOpts |
| 23 | wantsErr bool |
| 24 | wantsErrMsg string |
| 25 | wantsExporter bool |
| 26 | }{ |
| 27 | { |
| 28 | name: "not-a-number", |
| 29 | cli: "x", |
| 30 | wantsErr: true, |
| 31 | wantsErrMsg: "invalid number: x", |
| 32 | }, |
| 33 | { |
| 34 | name: "specify-repo-and-team", |
| 35 | cli: "--repo my-repo --team my-team", |
| 36 | wantsErr: true, |
| 37 | wantsErrMsg: "specify only one of `--repo` or `--team`", |
| 38 | }, |
| 39 | { |
| 40 | name: "specify-nothing", |
| 41 | cli: "", |
| 42 | wants: linkOpts{ |
| 43 | owner: "OWNER", |
| 44 | repo: "REPO", |
| 45 | }, |
| 46 | }, |
| 47 | { |
| 48 | name: "repo", |
| 49 | cli: "--repo my-repo", |
| 50 | wants: linkOpts{ |
| 51 | repo: "my-repo", |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | name: "repo-flag-contains-owner", |
| 56 | cli: "--repo monalisa/my-repo", |
| 57 | wants: linkOpts{ |
| 58 | owner: "monalisa", |
| 59 | repo: "my-repo", |
| 60 | }, |
| 61 | }, |
| 62 | { |
| 63 | name: "repo-flag-contains-owner-and-host", |
| 64 | cli: "--repo github.com/monalisa/my-repo", |
| 65 | wants: linkOpts{ |
| 66 | host: "github.com", |
| 67 | owner: "monalisa", |
| 68 | repo: "my-repo", |
| 69 | }, |
| 70 | }, |
| 71 | { |
| 72 | name: "repo-flag-contains-wrong-format", |
| 73 | cli: "--repo h/e/l/l/o", |
| 74 | wantsErr: true, |
| 75 | wantsErrMsg: "expected the \"[HOST/]OWNER/REPO\" or \"REPO\" format, got \"h/e/l/l/o\"", |