Skip to content

Commit

Permalink
add failure test case
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Lin <robert@bobheadxi.dev>
  • Loading branch information
bobheadxi committed Apr 5, 2020
1 parent 45b7a33 commit acecb20
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions internal/core/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,19 @@ func TestPipelineHeadCommit(t *testing.T) {
assert.False(t, out.CreatedBranchHash.IsZero())

pipeline := NewPipeline(repo)
pipeline.Branch = testBranch
commits, err := pipeline.HeadCommit()
assert.NoError(t, err)
assert.Len(t, commits, 1)
assert.True(t, len(commits[0].ParentHashes) > 0)
assert.Equal(t, out.CreatedBranchHash, commits[0].Hash)
t.Run("branch ok", func(t *testing.T) {
pipeline.Branch = testBranch
commits, err := pipeline.HeadCommit()
assert.NoError(t, err)
assert.Len(t, commits, 1)
assert.True(t, len(commits[0].ParentHashes) > 0)
assert.Equal(t, out.CreatedBranchHash, commits[0].Hash)
})
t.Run("branch does not exist", func(t *testing.T) {
pipeline.Branch = "not-a-branch"
_, err := pipeline.HeadCommit()
assert.Error(t, err)
})
})
}

Expand Down

0 comments on commit acecb20

Please sign in to comment.