MCPcopy Create free account
hub / github.com/cli/cli / TestCredentialPatternFromGitURL

Function TestCredentialPatternFromGitURL

git/client_test.go:2045–2079  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2043}
2044
2045func TestCredentialPatternFromGitURL(t *testing.T) {
2046 tests := []struct {
2047 name string
2048 gitURL string
2049 wantErr bool
2050 wantCredentialPattern CredentialPattern
2051 }{
2052 {
2053 name: "Given a well formed gitURL, it returns the corresponding CredentialPattern",
2054 gitURL: "https://github.com/OWNER/REPO.git",
2055 wantCredentialPattern: CredentialPattern{
2056 pattern: "https://github.com",
2057 allMatching: false,
2058 },
2059 },
2060 {
2061 name: "Given a malformed gitURL, it returns an error",
2062 // This pattern is copied from the tests in ParseURL
2063 // Unexpectedly, a non URL-like string did not error in ParseURL
2064 gitURL: "ssh://git@[/tmp/git-repo",
2065 wantErr: true,
2066 },
2067 }
2068 for _, tt := range tests {
2069 t.Run(tt.name, func(t *testing.T) {
2070 credentialPattern, err := CredentialPatternFromGitURL(tt.gitURL)
2071 if tt.wantErr {
2072 assert.ErrorContains(t, err, "failed to parse remote URL")
2073 } else {
2074 assert.NoError(t, err)
2075 assert.Equal(t, tt.wantCredentialPattern, credentialPattern)
2076 }
2077 })
2078 }
2079}
2080
2081func TestCredentialPatternFromHost(t *testing.T) {
2082 tests := []struct {

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected