| 165 | } |
| 166 | |
| 167 | func TestSetup_setOurs_nonGH(t *testing.T) { |
| 168 | cs, restoreRun := run.Stub() |
| 169 | defer restoreRun(t) |
| 170 | cs.Register(`git config --global --replace-all credential\.`, 0, "", func(args []string) { |
| 171 | if key := args[len(args)-2]; key != "credential.https://example.com.helper" { |
| 172 | t.Errorf("git config key was %q", key) |
| 173 | } |
| 174 | if val := args[len(args)-1]; val != "" { |
| 175 | t.Errorf("global credential helper configured to %q", val) |
| 176 | } |
| 177 | }) |
| 178 | cs.Register(`git config --global --add credential\.`, 0, "", func(args []string) { |
| 179 | if key := args[len(args)-2]; key != "credential.https://example.com.helper" { |
| 180 | t.Errorf("git config key was %q", key) |
| 181 | } |
| 182 | if val := args[len(args)-1]; val != "!/path/to/gh auth git-credential" { |
| 183 | t.Errorf("global credential helper configured to %q", val) |
| 184 | } |
| 185 | }) |
| 186 | |
| 187 | f := GitCredentialFlow{ |
| 188 | helper: gitcredentials.Helper{}, |
| 189 | HelperConfig: &gitcredentials.HelperConfig{ |
| 190 | SelfExecutablePath: "/path/to/gh", |
| 191 | GitClient: &git.Client{GitPath: "some/path/git"}, |
| 192 | }, |
| 193 | } |
| 194 | |
| 195 | if _, err := f.Setup("example.com", "monalisa", "PASSWD", false); err != nil { |
| 196 | t.Errorf("Setup() error = %v", err) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | func TestPrompt_expiring_configure(t *testing.T) { |
| 201 | var gotMessage string |