-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue with GH App credential not writing if lines already exist (#…
…3679) * Fix issue with GH App credential not writing if lines already exist * Fix lint issue of unused variable. --------- Co-authored-by: PePe Amengual <[email protected]> Co-authored-by: Dylan Page <[email protected]>
- Loading branch information
1 parent
078af70
commit 352bbed
Showing
2 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,25 @@ func TestWriteGitCreds_ReplaceApp(t *testing.T) { | |
Equals(t, expContets, string(actContents)) | ||
} | ||
|
||
// Test that the github app credential gets added even if there are other credentials. | ||
func TestWriteGitCreds_AppendAppWhenFileNotEmpty(t *testing.T) { | ||
logger := logging.NewNoopLogger(t) | ||
tmp := t.TempDir() | ||
t.Setenv("HOME", tmp) | ||
|
||
credsFile := filepath.Join(tmp, ".git-credentials") | ||
contents := "line1\nhttps://user:[email protected]\nline2" | ||
err := os.WriteFile(credsFile, []byte(contents), 0600) | ||
Ok(t, err) | ||
|
||
err = vcs.WriteGitCreds("x-access-token", "token", "github.com", tmp, logger, true) | ||
Ok(t, err) | ||
expContets := "line1\nhttps://user:[email protected]\nline2\nhttps://x-access-token:[email protected]" | ||
actContents, err := os.ReadFile(filepath.Join(tmp, ".git-credentials")) | ||
Ok(t, err) | ||
Equals(t, expContets, string(actContents)) | ||
} | ||
|
||
// Test that the github app credentials get updated when cred file is empty. | ||
func TestWriteGitCreds_AppendApp(t *testing.T) { | ||
logger := logging.NewNoopLogger(t) | ||
|