-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: only check for tags on the main repository when creating the en…
…vironments Signed-off-by: Daniel Gozalo <[email protected]> feat: added a test to the git helper fix: fixed the variables positions fix: fixed formatting on debug trace
- Loading branch information
1 parent
ba44ed1
commit c90e349
Showing
4 changed files
with
113 additions
and
23 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
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 |
---|---|---|
|
@@ -1811,3 +1811,46 @@ func TestPushRepoAndCreatePullRequest(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestGetGitInfoFromDirectory(t *testing.T) { | ||
t.Parallel() | ||
gitter := gits.NewGitCLI() | ||
owner := "fakeowner" | ||
repo := "fakerepo" | ||
originalRepo, err := gits.NewFakeRepository(owner, repo, func(dir string) error { | ||
err := ioutil.WriteFile(filepath.Join(dir, "README"), []byte("Hello!"), 0655) | ||
if err != nil { | ||
return errors.Wrapf(err, "writing README") | ||
} | ||
return nil | ||
}, gitter) | ||
defer os.RemoveAll(originalRepo.BaseDir) | ||
|
||
assert.NoError(t, err) | ||
dir, err := ioutil.TempDir("", "") | ||
defer os.RemoveAll(dir) | ||
assert.NoError(t, err) | ||
err = gitter.Clone(originalRepo.GitRepo.CloneURL, dir) | ||
assert.NoError(t, err) | ||
err = gitter.UpdateRemote(dir, fmt.Sprintf("[email protected]:%s/%s.git", owner, repo)) | ||
assert.NoError(t, err) | ||
|
||
url, ref, err := gits.GetGitInfoFromDirectory(dir, gitter) | ||
assert.NoError(t, err) | ||
|
||
assert.Equal(t, fmt.Sprintf("https://github.com/%s/%s", owner, repo), url) | ||
assert.Equal(t, "master", ref) | ||
} | ||
|
||
func TestGetGitInfoFromDirectoryNoGit(t *testing.T) { | ||
t.Parallel() | ||
gitter := gits.NewGitCLI() | ||
dir, err := ioutil.TempDir("", "") | ||
defer os.RemoveAll(dir) | ||
assert.NoError(t, err) | ||
|
||
_, _, err = gits.GetGitInfoFromDirectory(dir, gitter) | ||
assert.Error(t, err) | ||
|
||
assert.Equal(t, fmt.Sprintf("there was a problem obtaining the remote Git URL of directory %s: failed to unmarshal due to no GitConfDir defined", dir), err.Error()) | ||
} |