| 77 | } |
| 78 | |
| 79 | func 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 | } |