MCPcopy
hub / github.com/cli/cli / TestGitCredentialsSetup_setOurs_GH

Function TestGitCredentialsSetup_setOurs_GH

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

Source from the content-addressed store, hash-verified

27}
28
29func TestGitCredentialsSetup_setOurs_GH(t *testing.T) {
30 cs, restoreRun := run.Stub()
31 defer restoreRun(t)
32 cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) {
33 if key := args[len(args)-2]; key != "credential.https://github.com.helper" {
34 t.Errorf("git config key was %q", key)
35 }
36 if val := args[len(args)-1]; val != "" {
37 t.Errorf("global credential helper configured to %q", val)
38 }
39 })
40 cs.Register(`git config --global --add credential\.`, 0, "", func(args []string) {
41 if key := args[len(args)-2]; key != "credential.https://github.com.helper" {
42 t.Errorf("git config key was %q", key)
43 }
44 if val := args[len(args)-1]; val != "!/path/to/gh auth git-credential" {
45 t.Errorf("global credential helper configured to %q", val)
46 }
47 })
48 cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) {
49 if key := args[len(args)-2]; key != "credential.https://gist.github.com.helper" {
50 t.Errorf("git config key was %q", key)
51 }
52 if val := args[len(args)-1]; val != "" {
53 t.Errorf("global credential helper configured to %q", val)
54 }
55 })
56 cs.Register(`git config --global --add credential\.`, 0, "", func(args []string) {
57 if key := args[len(args)-2]; key != "credential.https://gist.github.com.helper" {
58 t.Errorf("git config key was %q", key)
59 }
60 if val := args[len(args)-1]; val != "!/path/to/gh auth git-credential" {
61 t.Errorf("global credential helper configured to %q", val)
62 }
63 })
64
65 f := GitCredentialFlow{
66 helper: gitcredentials.Helper{},
67 HelperConfig: &gitcredentials.HelperConfig{
68 SelfExecutablePath: "/path/to/gh",
69 GitClient: &git.Client{GitPath: "some/path/git"},
70 },
71 }
72
73 if err := f.Setup("github.com", "monalisa", "PASSWD"); err != nil {
74 t.Errorf("Setup() error = %v", err)
75 }
76
77}
78
79func TestSetup_setOurs_nonGH(t *testing.T) {
80 cs, restoreRun := run.Stub()

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