Skip to content

Commit

Permalink
#28 add tests for handling ApplicationFailed state
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-dammeier committed Feb 5, 2024
1 parent 865fb60 commit 7e847f6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/application/blueprintSpecChangeUseCase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,27 @@ func TestBlueprintSpecChangeUseCase_HandleChange(t *testing.T) {
require.NoError(t, err)
})

t.Run("handle Application failed", func(t *testing.T) {
// given
repoMock := newMockBlueprintSpecRepository(t)
validationMock := newMockBlueprintSpecValidationUseCase(t)
effectiveBlueprintMock := newMockEffectiveBlueprintUseCase(t)
stateDiffMock := newMockStateDiffUseCase(t)
doguInstallMock := newMockDoguInstallationUseCase(t)
applyMock := newMockApplyBlueprintSpecUseCase(t)
useCase := NewBlueprintSpecChangeUseCase(repoMock, validationMock, effectiveBlueprintMock, stateDiffMock, doguInstallMock, applyMock)

repoMock.EXPECT().GetById(testCtx, blueprintId).Return(&domain.BlueprintSpec{
Id: blueprintId,
Status: domain.StatusPhaseBlueprintApplicationFailed,
}, nil)
applyMock.EXPECT().PostProcessBlueprintApplication(testCtx, blueprintId).Return(nil)
// when
err := useCase.HandleChange(testCtx, blueprintId)
// then
require.NoError(t, err)
})

t.Run("handle failed blueprint", func(t *testing.T) {
// given
repoMock := newMockBlueprintSpecRepository(t)
Expand Down Expand Up @@ -533,3 +554,16 @@ func TestBlueprintSpecChangeUseCase_applyBlueprintSpec(t *testing.T) {
require.ErrorIs(t, err, assert.AnError)
})
}

func TestBlueprintSpecChangeUseCase_checkEcosystemHealthAfterwards(t *testing.T) {
t.Run("error", func(t *testing.T) {
// given
applyMock := newMockApplyBlueprintSpecUseCase(t)
applyMock.EXPECT().CheckEcosystemHealthAfterwards(testCtx, blueprintId).Return(assert.AnError)
useCase := NewBlueprintSpecChangeUseCase(nil, nil, nil, nil, nil, applyMock)
// when
err := useCase.checkEcosystemHealthAfterwards(testCtx, blueprintId)
// then
require.ErrorIs(t, err, assert.AnError)
})
}

0 comments on commit 7e847f6

Please sign in to comment.