Skip to content

Commit

Permalink
add mocks
Browse files Browse the repository at this point in the history
Signed-off-by: Alexy Mantha <alexy@mantha.dev>
  • Loading branch information
alexymantha committed Apr 2, 2024
1 parent 42679c9 commit 0962fb1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
6 changes: 3 additions & 3 deletions server/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ import (
appinformer "github.com/argoproj/argo-cd/v2/pkg/client/informers/externalversions"
"github.com/argoproj/argo-cd/v2/reposerver/apiclient"
"github.com/argoproj/argo-cd/v2/reposerver/apiclient/mocks"
appmocks "github.com/argoproj/argo-cd/v2/server/application/mocks"
servercache "github.com/argoproj/argo-cd/v2/server/cache"
"github.com/argoproj/argo-cd/v2/server/rbacpolicy"
"github.com/argoproj/argo-cd/v2/test"
"github.com/argoproj/argo-cd/v2/util/argo"
"github.com/argoproj/argo-cd/v2/util/assets"
broadcastermocks "github.com/argoproj/argo-cd/v2/util/broadcast/mocks"
"github.com/argoproj/argo-cd/v2/util/cache"
cacheutil "github.com/argoproj/argo-cd/v2/util/cache"
"github.com/argoproj/argo-cd/v2/util/cache/appstate"
Expand Down Expand Up @@ -221,7 +221,7 @@ func newTestAppServerWithEnforcerConfigure(f func(*rbac.Enforcer), t *testing.T,
panic("Timed out waiting for caches to sync")
}

broadcaster := new(appmocks.Broadcaster)
broadcaster := new(broadcastermocks.Broadcaster[appsv1.ApplicationWatchEvent])
broadcaster.On("Subscribe", mock.Anything, mock.Anything).Return(func() {}).Run(func(args mock.Arguments) {
// Simulate the broadcaster notifying the subscriber of an application update.
// The second parameter to Subscribe is filters. For the purposes of tests, we ignore the filters. Future tests
Expand Down Expand Up @@ -401,7 +401,7 @@ func newTestAppServerWithEnforcerConfigureWithBenchmark(f func(*rbac.Enforcer),
panic("Timed out waiting for caches to sync")
}

broadcaster := new(appmocks.Broadcaster)
broadcaster := new(broadcastermocks.Broadcaster[appsv1.ApplicationWatchEvent])
broadcaster.On("Subscribe", mock.Anything, mock.Anything).Return(func() {}).Run(func(args mock.Arguments) {
// Simulate the broadcaster notifying the subscriber of an application update.
// The second parameter to Subscribe is filters. For the purposes of tests, we ignore the filters. Future tests
Expand Down
4 changes: 2 additions & 2 deletions server/applicationset/applicationset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

appsetmocks "github.com/argoproj/argo-cd/v2/server/applicationset/mocks"
broadcastermocks "github.com/argoproj/argo-cd/v2/util/broadcast/mocks"
"github.com/argoproj/pkg/sync"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -150,7 +150,7 @@ func newTestAppSetServerWithEnforcerConfigure(f func(*rbac.Enforcer), namespace
panic("Timed out waiting for caches to sync")
}

broadcaster := new(appsetmocks.Broadcaster)
broadcaster := new(broadcastermocks.Broadcaster[appsv1.ApplicationSetWatchEvent])
broadcaster.On("Subscribe", mock.Anything, mock.Anything).Return(func() {}).Run(func(args mock.Arguments) {
// Simulate the broadcaster notifying the subscriber of an applicationset update.
// The second parameter to Subscribe is filters. For the purposes of tests, we ignore the filters. Future tests
Expand Down
66 changes: 66 additions & 0 deletions util/broadcast/mocks/Broadcaster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0962fb1

Please sign in to comment.