Reorganized tests
This commit is contained in:
parent
79da79fb68
commit
21691c8d2e
1 changed files with 47 additions and 56 deletions
|
|
@ -138,23 +138,55 @@ func Test_runBrowse(t *testing.T) {
|
|||
opts: BrowseOptions{
|
||||
SelectorArg: "",
|
||||
},
|
||||
baseRepo: ghrepo.New("jessica", "cli"),
|
||||
expectedURL: "https://github.com/jessica/cli",
|
||||
baseRepo: ghrepo.New("jlsestak", "cli"),
|
||||
expectedURL: "https://github.com/jlsestak/cli",
|
||||
},
|
||||
{
|
||||
name: "settings flag",
|
||||
opts: BrowseOptions{
|
||||
SettingsFlag: true,
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "ObscuredByClouds"),
|
||||
expectedURL: "https://github.com/bchadwic/ObscuredByClouds/settings",
|
||||
},
|
||||
{
|
||||
name: "projects flag",
|
||||
opts: BrowseOptions{
|
||||
ProjectsFlag: true,
|
||||
},
|
||||
baseRepo: ghrepo.New("ttran112", "7ate9"),
|
||||
expectedURL: "https://github.com/ttran112/7ate9/projects",
|
||||
},
|
||||
{
|
||||
name: "wiki flag",
|
||||
opts: BrowseOptions{
|
||||
WikiFlag: true,
|
||||
},
|
||||
baseRepo: ghrepo.New("ravocean", "ThreatLevelMidnight"),
|
||||
expectedURL: "https://github.com/ravocean/ThreatLevelMidnight/wiki",
|
||||
},
|
||||
{
|
||||
name: "file argument",
|
||||
opts: BrowseOptions{SelectorArg: "path/to/file.txt"},
|
||||
baseRepo: ghrepo.New("ken", "cli"),
|
||||
baseRepo: ghrepo.New("ken", "mrprofessor"),
|
||||
defaultBranch: "main",
|
||||
expectedURL: "https://github.com/ken/cli/tree/main/path/to/file.txt",
|
||||
expectedURL: "https://github.com/ken/mrprofessor/tree/main/path/to/file.txt",
|
||||
},
|
||||
{
|
||||
name: "issue argument",
|
||||
opts: BrowseOptions{
|
||||
SelectorArg: "217",
|
||||
},
|
||||
baseRepo: ghrepo.New("kevin", "MinTy"),
|
||||
expectedURL: "https://github.com/kevin/MinTy/issues/217",
|
||||
},
|
||||
{
|
||||
name: "branch flag",
|
||||
opts: BrowseOptions{
|
||||
Branch: "trunk",
|
||||
},
|
||||
baseRepo: ghrepo.New("thanh", "cli"),
|
||||
expectedURL: "https://github.com/thanh/cli/tree/trunk/",
|
||||
baseRepo: ghrepo.New("jlsestak", "vegan"),
|
||||
expectedURL: "https://github.com/jlsestak/vegan/tree/trunk/",
|
||||
},
|
||||
{
|
||||
name: "branch flag with file",
|
||||
|
|
@ -162,56 +194,24 @@ func Test_runBrowse(t *testing.T) {
|
|||
Branch: "trunk",
|
||||
SelectorArg: "main.go",
|
||||
},
|
||||
baseRepo: ghrepo.New("thanh", "cli"),
|
||||
expectedURL: "https://github.com/thanh/cli/tree/trunk/main.go",
|
||||
},
|
||||
{
|
||||
name: "settings flag",
|
||||
opts: BrowseOptions{
|
||||
SettingsFlag: true,
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
expectedURL: "https://github.com/bchadwic/cli/settings",
|
||||
},
|
||||
{
|
||||
name: "projects flag",
|
||||
opts: BrowseOptions{
|
||||
ProjectsFlag: true,
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
expectedURL: "https://github.com/bchadwic/cli/projects",
|
||||
},
|
||||
{
|
||||
name: "wiki flag",
|
||||
opts: BrowseOptions{
|
||||
WikiFlag: true,
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
expectedURL: "https://github.com/bchadwic/cli/wiki",
|
||||
},
|
||||
{
|
||||
name: "issue argument",
|
||||
opts: BrowseOptions{
|
||||
SelectorArg: "217",
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
expectedURL: "https://github.com/bchadwic/cli/issues/217",
|
||||
baseRepo: ghrepo.New("bchadwic", "LedZeppelinIV"),
|
||||
expectedURL: "https://github.com/bchadwic/LedZeppelinIV/tree/trunk/main.go",
|
||||
},
|
||||
{
|
||||
name: "file with line number",
|
||||
opts: BrowseOptions{
|
||||
SelectorArg: "path/to/file.txt:32",
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
baseRepo: ghrepo.New("ravocean", "angur"),
|
||||
defaultBranch: "trunk",
|
||||
expectedURL: "https://github.com/bchadwic/cli/tree/trunk/path/to/file.txt#L32",
|
||||
expectedURL: "https://github.com/ravocean/angur/tree/trunk/path/to/file.txt#L32",
|
||||
},
|
||||
{
|
||||
name: "file with invalid line number",
|
||||
opts: BrowseOptions{
|
||||
SelectorArg: "path/to/file.txt:32:32",
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
baseRepo: ghrepo.New("ttran112", "ttrain211"),
|
||||
wantsErr: true,
|
||||
},
|
||||
{
|
||||
|
|
@ -220,27 +220,18 @@ func Test_runBrowse(t *testing.T) {
|
|||
SelectorArg: "217",
|
||||
Branch: "trunk",
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
baseRepo: ghrepo.New("ken", "grc"),
|
||||
wantsErr: false,
|
||||
expectedURL: "https://github.com/bchadwic/cli/issues/217",
|
||||
expectedURL: "https://github.com/ken/grc/issues/217",
|
||||
},
|
||||
{
|
||||
name: "opening branch",
|
||||
opts: BrowseOptions{
|
||||
Branch: "first-browse-pull",
|
||||
},
|
||||
baseRepo: ghrepo.New("ravocean", "cli"),
|
||||
baseRepo: ghrepo.New("github", "ThankYouGitHub"),
|
||||
wantsErr: false,
|
||||
expectedURL: "https://github.com/ravocean/cli/tree/first-browse-pull/",
|
||||
},
|
||||
{
|
||||
name: "file with line argument",
|
||||
opts: BrowseOptions{
|
||||
SelectorArg: "path/to/file.txt:32",
|
||||
},
|
||||
baseRepo: ghrepo.New("bchadwic", "cli"),
|
||||
defaultBranch: "trunk",
|
||||
expectedURL: "https://github.com/bchadwic/cli/tree/trunk/path/to/file.txt#L32",
|
||||
expectedURL: "https://github.com/github/ThankYouGitHub/tree/first-browse-pull/",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue