Support for [HOST/]OWNER/REPO format

This commit is contained in:
benebsiny 2024-02-15 23:16:00 +08:00
parent 874da37a24
commit 7dfaa328aa
4 changed files with 241 additions and 21 deletions

View file

@ -49,6 +49,35 @@ func TestNewCmdUnlink(t *testing.T) {
repo: "my-repo",
},
},
{
name: "repo-flag-contains-owner",
cli: "--repo monalisa/my-repo",
wants: unlinkOpts{
owner: "monalisa",
repo: "my-repo",
},
},
{
name: "repo-flag-contains-owner-and-host",
cli: "--repo github.com/monalisa/my-repo",
wants: unlinkOpts{
host: "github.com",
owner: "monalisa",
repo: "my-repo",
},
},
{
name: "repo-flag-contains-wrong-format",
cli: "--repo h/e/l/l/o",
wantsErr: true,
wantsErrMsg: "expected the \"[HOST/]OWNER/REPO\" or \"REPO\" format, got \"h/e/l/l/o\"",
},
{
name: "repo-flag-with-owner-different-from-owner-flag",
cli: "--repo monalisa/my-repo --owner leonardo",
wantsErr: true,
wantsErrMsg: "'monalisa/my-repo' has different owner from 'leonardo'",
},
{
name: "team",
cli: "--team my-team",
@ -56,6 +85,35 @@ func TestNewCmdUnlink(t *testing.T) {
team: "my-team",
},
},
{
name: "team-flag-contains-owner",
cli: "--team my-org/my-team",
wants: unlinkOpts{
owner: "my-org",
team: "my-team",
},
},
{
name: "team-flag-contains-owner-and-host",
cli: "--team github.com/my-org/my-team",
wants: unlinkOpts{
host: "github.com",
owner: "my-org",
team: "my-team",
},
},
{
name: "team-flag-contains-wrong-format",
cli: "--team h/e/l/l/o",
wantsErr: true,
wantsErrMsg: "expected the \"[HOST/]OWNER/TEAM\" or \"TEAM\" format, got \"h/e/l/l/o\"",
},
{
name: "team-flag-with-owner-different-from-owner-flag",
cli: "--team my-org/my-team --owner her-org",
wantsErr: true,
wantsErrMsg: "'my-org/my-team' has different owner from 'her-org'",
},
{
name: "number",
cli: "123 --repo my-repo",