MCPcopy Index your code
hub / github.com/cli/cli / TestSetup_setOurs_nonGH

Function TestSetup_setOurs_nonGH

pkg/cmd/auth/shared/git_credential_test.go:79–110  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestSetup_setOurs_nonGH(t *testing.T) {
80 cs, restoreRun := run.Stub()
81 defer restoreRun(t)
82 cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) {
83 if key := args[len(args)-2]; key != "credential.https://example.com.helper" {
84 t.Errorf("git config key was %q", key)
85 }
86 if val := args[len(args)-1]; val != "" {
87 t.Errorf("global credential helper configured to %q", val)
88 }
89 })
90 cs.Register(`git config --global --add credential\.`, 0, "", func(args []string) {
91 if key := args[len(args)-2]; key != "credential.https://example.com.helper" {
92 t.Errorf("git config key was %q", key)
93 }
94 if val := args[len(args)-1]; val != "!/path/to/gh auth git-credential" {
95 t.Errorf("global credential helper configured to %q", val)
96 }
97 })
98
99 f := GitCredentialFlow{
100 helper: gitcredentials.Helper{},
101 HelperConfig: &gitcredentials.HelperConfig{
102 SelfExecutablePath: "/path/to/gh",
103 GitClient: &git.Client{GitPath: "some/path/git"},
104 },
105 }
106
107 if err := f.Setup("example.com", "monalisa", "PASSWD"); err != nil {
108 t.Errorf("Setup() error = %v", err)
109 }
110}

Callers

nothing calls this directly

Calls 4

SetupMethod · 0.95
StubFunction · 0.92
ErrorfMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected