Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: kim-codefresh <[email protected]>
  • Loading branch information
kim-codefresh committed Jan 11, 2023
1 parent 53d3ca5 commit bec397a
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions pkg/git/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1565,18 +1565,52 @@ func Test_validateRepoWritePermission(t *testing.T) {
wantErr bool
beforeFn func(r *mocks.MockRepository, w *mocks.MockWorktree)
}{
"Should fail getting git log": {
"Should fail if push context failed": {
opts: nil,
wantErr: true,
beforeFn: func(r *mocks.MockRepository, w *mocks.MockWorktree) {
r.EXPECT().PushContext(gomock.Any(), &gg.PushOptions{
Auth: nil,
Progress: os.Stderr,
}).
Times(1).
Return(gg.NoErrAlreadyUpToDate).
Times(1).
Return(fmt.Errorf("some error"))
w.EXPECT().AddGlob(gomock.Any()).
Times(1).
Return(nil)
w.EXPECT().Commit("Validating repository write permission", gomock.Any()).
Times(1).
Return(plumbing.Hash{}, nil)
},
},
"Should fail if commit failed": {
opts: nil,
wantErr: true,
beforeFn: func(r *mocks.MockRepository, w *mocks.MockWorktree) {
w.EXPECT().AddGlob(gomock.Any()).
Times(1).
Return(nil)
w.EXPECT().Commit("Validating repository write permission", gomock.Any()).
Times(1).
Return(plumbing.Hash{}, fmt.Errorf("some error"))
},
},
"Should succeed if push context succeed": {
opts: nil,
wantErr: false,
beforeFn: func(r *mocks.MockRepository, w *mocks.MockWorktree) {
r.EXPECT().PushContext(gomock.Any(), &gg.PushOptions{
Auth: nil,
Progress: os.Stderr,
}).
Times(1).
Return(nil)
w.EXPECT().AddGlob(gomock.Any()).
Times(1).
Return(nil)
w.EXPECT().Commit("Validating repository write permission", gomock.Any()).
Times(1).
Return(plumbing.Hash{}, nil)
},
},
}
Expand Down

0 comments on commit bec397a

Please sign in to comment.