Skip to content

Commit

Permalink
chore: Tidy up variable name in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jan 2, 2023
1 parent 3d057e8 commit 5e7063e
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions pkg/cmd/initcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,93 +14,93 @@ import (

func TestGuessRepoURL(t *testing.T) {
for _, tc := range []struct {
arg string
expectedHTTPRepoURL string
expectedHTTPUsername string
expectedSSHRepoURL string
arg string
expectedHTTPRepoURL string
expectedSSHRepoURL string
expectedUsername string
}{
{
arg: "git@github.com:user/dotfiles.git",
expectedHTTPRepoURL: "git@github.com:user/dotfiles.git",
expectedSSHRepoURL: "git@github.com:user/dotfiles.git",
},
{
arg: "codeberg.org/user",
expectedHTTPRepoURL: "https://codeberg.org/user/dotfiles.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@codeberg.org:user/dotfiles.git",
arg: "codeberg.org/user",
expectedHTTPRepoURL: "https://codeberg.org/user/dotfiles.git",
expectedSSHRepoURL: "git@codeberg.org:user/dotfiles.git",
expectedUsername: "user",
},
{
arg: "codeberg.org/user/dots",
expectedHTTPRepoURL: "https://codeberg.org/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@codeberg.org:user/dots.git",
arg: "codeberg.org/user/dots",
expectedHTTPRepoURL: "https://codeberg.org/user/dots.git",
expectedSSHRepoURL: "git@codeberg.org:user/dots.git",
expectedUsername: "user",
},
{
arg: "gitlab.com/user",
expectedHTTPRepoURL: "https://gitlab.com/user/dotfiles.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@gitlab.com:user/dotfiles.git",
arg: "gitlab.com/user",
expectedHTTPRepoURL: "https://gitlab.com/user/dotfiles.git",
expectedSSHRepoURL: "git@gitlab.com:user/dotfiles.git",
expectedUsername: "user",
},
{
arg: "gitlab.com/user/dots",
expectedHTTPRepoURL: "https://gitlab.com/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
arg: "gitlab.com/user/dots",
expectedHTTPRepoURL: "https://gitlab.com/user/dots.git",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
expectedUsername: "user",
},
{
arg: "gitlab.com/user/dots.git",
expectedHTTPRepoURL: "https://gitlab.com/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
arg: "gitlab.com/user/dots.git",
expectedHTTPRepoURL: "https://gitlab.com/user/dots.git",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
expectedUsername: "user",
},
{
arg: "http://gitlab.com/user/dots.git",
expectedHTTPRepoURL: "http://gitlab.com/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
arg: "http://gitlab.com/user/dots.git",
expectedHTTPRepoURL: "http://gitlab.com/user/dots.git",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
expectedUsername: "user",
},
{
arg: "https://gitlab.com/user/dots.git",
expectedHTTPRepoURL: "https://gitlab.com/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
arg: "https://gitlab.com/user/dots.git",
expectedHTTPRepoURL: "https://gitlab.com/user/dots.git",
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
expectedUsername: "user",
},
{
arg: "sr.ht/~user_name",
expectedHTTPRepoURL: "https://git.sr.ht/~user_name/dotfiles",
expectedHTTPUsername: "user_name",
expectedSSHRepoURL: "git@git.sr.ht:~user_name/dotfiles",
arg: "sr.ht/~user_name",
expectedHTTPRepoURL: "https://git.sr.ht/~user_name/dotfiles",
expectedSSHRepoURL: "git@git.sr.ht:~user_name/dotfiles",
expectedUsername: "user_name",
},
{
arg: "sr.ht/~user_name/dots",
expectedHTTPRepoURL: "https://git.sr.ht/~user_name/dots",
expectedHTTPUsername: "user_name",
expectedSSHRepoURL: "git@git.sr.ht:~user_name/dots",
arg: "sr.ht/~user_name/dots",
expectedHTTPRepoURL: "https://git.sr.ht/~user_name/dots",
expectedSSHRepoURL: "git@git.sr.ht:~user_name/dots",
expectedUsername: "user_name",
},
{
arg: "user",
expectedHTTPRepoURL: "https://github.com/user/dotfiles.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@github.com:user/dotfiles.git",
arg: "user",
expectedHTTPRepoURL: "https://github.com/user/dotfiles.git",
expectedSSHRepoURL: "git@github.com:user/dotfiles.git",
expectedUsername: "user",
},
{
arg: "user/dots",
expectedHTTPRepoURL: "https://github.com/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@github.com:user/dots.git",
arg: "user/dots",
expectedHTTPRepoURL: "https://github.com/user/dots.git",
expectedSSHRepoURL: "git@github.com:user/dots.git",
expectedUsername: "user",
},
{
arg: "user/dots.git",
expectedHTTPRepoURL: "https://github.com/user/dots.git",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@github.com:user/dots.git",
arg: "user/dots.git",
expectedHTTPRepoURL: "https://github.com/user/dots.git",
expectedSSHRepoURL: "git@github.com:user/dots.git",
expectedUsername: "user",
},
} {
t.Run(tc.arg, func(t *testing.T) {
ssh := false
actualHTTPUsername, actualHTTPRepoURL := guessRepoURL(tc.arg, ssh)
assert.Equal(t, tc.expectedHTTPUsername, actualHTTPUsername, "HTTPUsername")
assert.Equal(t, tc.expectedUsername, actualHTTPUsername, "HTTPUsername")
assert.Equal(t, tc.expectedHTTPRepoURL, actualHTTPRepoURL, "HTTPRepoURL")

ssh = true
Expand Down

0 comments on commit 5e7063e

Please sign in to comment.