-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change pod labels test to mock (#190)
- Loading branch information
1 parent
0828724
commit e296bb4
Showing
4 changed files
with
753 additions
and
244 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/operator/controllers/intents_reconcilers/client_matcher.go
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,37 @@ | ||
package intents_reconcilers | ||
|
||
import ( | ||
"github.com/golang/mock/gomock" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type ClientPatch struct { | ||
client.Patch | ||
} | ||
|
||
func (p ClientPatch) Matches(x interface{}) bool { | ||
patch := x.(client.Patch) | ||
actualData, err := patch.Data(nil) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
expectedData, err := p.Data(nil) | ||
if err != nil { | ||
return false | ||
} | ||
|
||
return string(actualData) == string(expectedData) && patch.Type() == p.Type() | ||
} | ||
|
||
func (p ClientPatch) String() string { | ||
data, err := p.Data(nil) | ||
if err != nil { | ||
return "format error" | ||
} | ||
return string(data) | ||
} | ||
|
||
func MatchPatch(patch client.Patch) gomock.Matcher { | ||
return ClientPatch{patch} | ||
} |
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,3 @@ | ||
package intents_reconcilers | ||
|
||
//go:generate go run github.com/golang/mock/mockgen@v1.6.0 -destination=./mocks/mock_k8s_client.go -package=intentsreconcilersmocks sigs.k8s.io/controller-runtime/pkg/client Client |
228 changes: 228 additions & 0 deletions
228
src/operator/controllers/intents_reconcilers/mocks/mock_k8s_client.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.