Skip to content

Commit

Permalink
remove ugly private mockgen workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Apr 14, 2023
1 parent 4ee60e3 commit 60e9ade
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 80 deletions.
54 changes: 27 additions & 27 deletions p2p/host/basic/mock_nat_test.go

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

49 changes: 0 additions & 49 deletions p2p/host/basic/mockgen_private.sh

This file was deleted.

6 changes: 6 additions & 0 deletions p2p/host/basic/mocks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build gomock || generate

package basichost

//go:generate sh -c "go run github.com/golang/mock/mockgen -build_flags=\"-tags=gomock\" -package basichost -destination mock_nat_test.go github.com/libp2p/go-libp2p/p2p/host/basic NAT"
type NAT nat
6 changes: 2 additions & 4 deletions p2p/host/basic/natmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ import (
"github.com/golang/mock/gomock"
)

//go:generate sh -c "./mockgen_private.sh basichost mock_nat_test.go github.com/libp2p/go-libp2p/p2p/host/basic nat"

func setupMockNAT(t *testing.T) (mockNAT *MockNat, reset func()) {
func setupMockNAT(t *testing.T) (mockNAT *MockNAT, reset func()) {
t.Helper()
ctrl := gomock.NewController(t)
mockNAT = NewMockNat(ctrl)
mockNAT = NewMockNAT(ctrl)
origDiscoverNAT := discoverNAT
discoverNAT = func(ctx context.Context) (nat, error) { return mockNAT, nil }
return mockNAT, func() {
Expand Down

0 comments on commit 60e9ade

Please sign in to comment.