Skip to content

Commit

Permalink
fix unittest (don't compare function pointers)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Sep 25, 2023
1 parent d6b3cf7 commit 389e935
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
1 change: 0 additions & 1 deletion api/environments/environment_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,6 @@ func Test_GetEnvironmentEvents_Handler(t *testing.T) {
nsFunc := event.RadixEnvironmentNamespace(raBuilder.BuildRA(), anyEnvironment)
eventHandler.EXPECT().
GetEvents(context.Background(), controllertest.EqualsNamespaceFunc(nsFunc)).
Return(make([]*eventModels.Event, 0), fmt.Errorf("err")).
Return([]*eventModels.Event{{}, {}}, nil).
Times(1)

Expand Down
13 changes: 2 additions & 11 deletions api/test/gomock_matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,8 @@ func (m namespaceFuncMatcher) Matches(arg interface{}) bool {
return false
}

// Not equal if function pointer is different
if argv.Pointer() != fv.Pointer() {
return false
}

// Not equal if functions return different value
if m.f() != arg.(event.NamespaceFunc)() {
return false
}

return true
// equal if functions return same value
return m.f() == arg.(event.NamespaceFunc)()
}

func (m namespaceFuncMatcher) String() string {
Expand Down

0 comments on commit 389e935

Please sign in to comment.