From 94e75f1b5c5da7461c86c0d431769115766c7295 Mon Sep 17 00:00:00 2001 From: Robert Lin Date: Sun, 5 Apr 2020 15:01:51 -0700 Subject: [PATCH] add failure test case Signed-off-by: Robert Lin --- internal/core/pipeline_test.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/core/pipeline_test.go b/internal/core/pipeline_test.go index c60d77c5..79e1b589 100644 --- a/internal/core/pipeline_test.go +++ b/internal/core/pipeline_test.go @@ -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) + }) }) }