Skip to content

Commit

Permalink
CI: Generate mocks and validate diff (#1215)
Browse files Browse the repository at this point in the history
Benefits:
- Sometimes mock files that should have been deleted still linger around
  the repo. Deleting and re-generating the files catches those cases.
- Less script code
  • Loading branch information
orestisfl authored Aug 14, 2023
1 parent 3ecb085 commit 8c70d9a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 139 deletions.
6 changes: 4 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ generate-mocks:

# run to validate no mocks are missing
validate-mocks:
./scripts/validate-mocks.sh

# delete and re-generate files to check nothing is different / missing
find . -name 'mock_*.go' -exec rm -f {} \;
just generate-mocks
git diff --exit-code

#### TESTS ####

Expand Down
4 changes: 2 additions & 2 deletions resources/providers/gcplib/auth/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func createServiceAccountFile(t *testing.T) *os.File {
return f
}

func mockGoogleAuthProvider(err error) *MockGoogleProviderAPI {
googleProviderAPI := &MockGoogleProviderAPI{}
func mockGoogleAuthProvider(err error) *MockGoogleAuthProviderAPI {
googleProviderAPI := &MockGoogleAuthProviderAPI{}
on := googleProviderAPI.EXPECT().FindDefaultCredentials(mock.Anything)
if err == nil {
on.Return(
Expand Down
109 changes: 0 additions & 109 deletions resources/providers/gcplib/auth/mock_google_provider_api.go

This file was deleted.

26 changes: 0 additions & 26 deletions scripts/validate-mocks.sh

This file was deleted.

0 comments on commit 8c70d9a

Please sign in to comment.