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

Function TestClientAuthenticatedCommandScopesCredentialHelperToPattern

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

Source from the content-addressed store, hash-verified

81}
82
83func TestClientAuthenticatedCommandScopesCredentialHelperToPattern(t *testing.T) {
84 // Given a client with an explicit gh executable
85 client := Client{
86 GhPath: "path/to/gh",
87 GitPath: "path/to/git",
88 }
89
90 // When an authenticated command is created for one credential pattern
91 cmd, err := client.AuthenticatedCommand(t.Context(), CredentialPattern{pattern: "https://github.com"}, "fetch")
92
93 // Then existing helpers are cleared and gh receives credentials only for that pattern
94 require.NoError(t, err)
95 assert.Equal(t, []string{"path/to/git", "-c", "credential.https://github.com.helper=", "-c", `credential.https://github.com.helper=!"path/to/gh" auth git-credential`, "fetch"}, cmd.Args)
96}
97
98func TestClientAuthenticatedCommandDefaultsToGhOnPath(t *testing.T) {
99 // Given a client without an explicit gh executable

Callers

nothing calls this directly

Calls 2

AuthenticatedCommandMethod · 0.95
EqualMethod · 0.80

Tested by

no test coverage detected