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 12, 2023
1 parent 865ebf4 commit cf2e70d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 79 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
// +build gomock

package basichost

type NAT nat
6 changes: 3 additions & 3 deletions p2p/host/basic/natmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ 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"
//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"

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 cf2e70d

Please sign in to comment.