Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
add a new test for getLatestTag.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Jul 22, 2017
1 parent c7b5145 commit b0cb910
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ type GitTagDetails struct {
CommitDate time.Time
}

// Clone a git repo into a local directory.
// Credentials need to be specified by embedding in gitRemote url.
// TODO: this pattern may not work on Bitbucket/GitLab
func GitClone(parentPath string, repositoryName string, gitRemote string) (string, error) {
//TODO: credentials may need to be specified
absPath, aerr := filepath.Abs(path.Join(parentPath, repositoryName))
if aerr != nil {
return "", aerr
Expand Down
14 changes: 14 additions & 0 deletions pkg/utils/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@ func TestGitLatestTaggedCommit(t *testing.T) {

}

func TestGitLatestTaggedCommit_InvalidDirectory(t *testing.T) {
t.Parallel()

//setup
dirPath := path.Join("this", "path", "does", "not", "exist")

//test
tag, ferr := utils.GitLatestTaggedCommit(dirPath)

//assert
require.Error(t, ferr)
require.Empty(t, tag)
}

func TestGitGenerateChangelog(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit b0cb910

Please sign in to comment.