-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/shini4i/argo-watcher/cmd/argo-watcher/mock" | ||
"github.com/shini4i/argo-watcher/internal/models" | ||
) | ||
|
||
func TestArgoStatusUpdaterCheck(t *testing.T) { | ||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
t.Run("Status Updater - ArgoCD cannot fetch app information", func(t *testing.T) { | ||
// mocks | ||
apiMock := mock.NewMockArgoApiInterface(ctrl) | ||
metricsMock := mock.NewMockMetricsInterface(ctrl) | ||
stateMock := mock.NewMockState(ctrl) | ||
|
||
task := models.Task{ | ||
Id: "test-id", | ||
App: "test-app", | ||
} | ||
// mock calls | ||
apiMock.EXPECT().GetApplication(task.App).Return(nil, fmt.Errorf("Unexpected failure")) | ||
metricsMock.EXPECT().AddFailedDeployment(task.App) | ||
stateMock.EXPECT().SetTaskStatus(task.Id, models.StatusFailedMessage, "ArgoCD API Error: Unexpected failure") | ||
|
||
// argo manager | ||
argo := &Argo{} | ||
argo.Init(stateMock, apiMock, metricsMock) | ||
|
||
// argo updater | ||
updater := &ArgoStatusUpdater{} | ||
updater.Init(*argo, 1, "test-registry") | ||
|
||
// run the rollout | ||
updater.WaitForRollout(task) | ||
}) | ||
} |