Skip to content

Commit 61e0112

Browse files
authored
Version control and vendor mockgen (microsoft#1802)
Explicitly track `github.com/golang/mock/mockgen` as a go dependency. (There is no change in our go.mod or go.sum, since the package is already being used by the generated code and elsewhere). Add `//go:generate` directives to create the mocked files and ensure the results are always up to date. Signed-off-by: Hamza El-Saawy <[email protected]>
1 parent 7193878 commit 61e0112

39 files changed

Lines changed: 23265 additions & 10 deletions

internal/computeagent/doc.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//
44
// A mock service under `mock` is used for unit testing the various services
55
// used for ncproxy.
6-
//
7-
// The mock service is compiled using the following command:
8-
//
9-
// mockgen -source="computeagent.pb.go" -package="computeagent_mock" > mock\computeagent_mock.pb.go
106
package computeagent
7+
8+
//go:generate go run github.com/golang/mock/mockgen -source=computeagent.pb.go -package=computeagent_mock -destination=mock\computeagent_mock.pb.go

pkg/ncproxy/nodenetsvc/v1/doc.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
//
44
// A mock service under `mock` is used for unit testing the various services
55
// used for ncproxy.
6-
//
7-
// The mock service is compiled using the following command:
8-
//
9-
// mockgen -source="nodenetsvc.pb.go" -package="nodenetsvc_mock" > mock\nodenetsvc_mock.pb.go
10-
116
package v1
7+
8+
//go:generate go run github.com/golang/mock/mockgen -source=nodenetsvc.pb.go -package=nodenetsvc_v1_mock -destination=mock\nodenetsvc_mock.pb.go

test/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ require (
5252
github.com/godbus/dbus/v5 v5.0.6 // indirect
5353
github.com/gogo/googleapis v1.4.0 // indirect
5454
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
55+
github.com/golang/mock v1.6.0 // indirect
5556
github.com/golang/protobuf v1.5.3 // indirect
5657
github.com/google/uuid v1.3.0 // indirect
5758
github.com/hashicorp/errwrap v1.1.0 // indirect

test/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
517517
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
518518
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
519519
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
520+
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
520521
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
521522
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
522523
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=

tools.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22

33
package hcsshim
44

5-
import _ "github.com/Microsoft/go-winio/tools/mkwinsyscall"
5+
import (
6+
// for go generate directives
7+
8+
// generate Win32 API code
9+
_ "github.com/Microsoft/go-winio/tools/mkwinsyscall"
10+
11+
// mock gRPC client and servers
12+
_ "github.com/golang/mock/mockgen"
13+
)

0 commit comments

Comments
 (0)