Skip to content

Commit 313cb03

Browse files
committed
add failure test case
1 parent 45b7a33 commit 313cb03

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

internal/core/pipeline_test.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,19 @@ func TestPipelineHeadCommit(t *testing.T) {
459459
assert.False(t, out.CreatedBranchHash.IsZero())
460460

461461
pipeline := NewPipeline(repo)
462-
pipeline.Branch = testBranch
463-
commits, err := pipeline.HeadCommit()
464-
assert.NoError(t, err)
465-
assert.Len(t, commits, 1)
466-
assert.True(t, len(commits[0].ParentHashes) > 0)
467-
assert.Equal(t, out.CreatedBranchHash, commits[0].Hash)
462+
t.Run("branch ok", func(t *testing.T) {
463+
pipeline.Branch = testBranch
464+
commits, err := pipeline.HeadCommit()
465+
assert.NoError(t, err)
466+
assert.Len(t, commits, 1)
467+
assert.True(t, len(commits[0].ParentHashes) > 0)
468+
assert.Equal(t, out.CreatedBranchHash, commits[0].Hash)
469+
})
470+
t.Run("branch does not exist", func(t *testing.T) {
471+
pipeline.Branch = "not-a-branch"
472+
_, err := pipeline.HeadCommit()
473+
assert.Error(t, err)
474+
})
468475
})
469476
}
470477

0 commit comments

Comments
 (0)