diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b5e2c25b..fd363ee2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,27 +1,32 @@ name: Run tests on: push: - branches: [main] + branches: ['*'] pull_request: - branches: [main] + branches: ['*'] + +permissions: + contents: read + env: GO111MODULE: on + jobs: test: strategy: matrix: - go-version: [1.15.x, 1.18.x] + go-version: [1.19.x, 1.20.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - name: Install Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Vet and build run: | @@ -30,23 +35,17 @@ jobs: - name: Install mockgen run: | - go install github.com/golang/mock/mockgen + go install go.uber.org/mock/mockgen - name: Run test script run: | ./ci/test.sh ./ci/check_panic_handling.sh - - name: Run Go tests all - if: ${{ startsWith(matrix.go-version, '1.18') }} + - name: Run Tests run: | for i in $(find $PWD -name go.mod); do pushd $(dirname $i) go test ./... popd done - - - name: Run Go tests some - if: ${{ startsWith(matrix.go-version, '1.18') == false }} - run: | - go test ./... diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..704e9623 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog +All notable changes to this project will be documented in this file. + +This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## 0.1.0 (29 Jun 2023) + +This is a minor version that mirrors the original golang/mock +project that this project originates from. + +Any users on golang/mock project should be able to migrate to +this project as-is, and expect exact same set of features (apart +from supported Go versions. See [README](README.md#supported-go-versions) +for more details. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c12995e2..fe7357b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ First off, thank you for taking an interest to contribute to this project! ## Opening issues -When opening a [new issue](https://github.com/golang/mock/issues/new/choose) +When opening a [new issue](https://github.com/uber/mock/issues/new/choose) please: 1. Make sure there are not other open/closed issues asking/reporting/requesting diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 00000000..a6d9819d --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,5 @@ +# This is the current list of maintainers to Uber's fork of gomock repository. + +Sung Yoon Whang +Ryan Hang +Zhongpeng Lin diff --git a/README.md b/README.md index a4213e50..13791d33 100644 --- a/README.md +++ b/README.md @@ -6,30 +6,21 @@ gomock is a mocking framework for the [Go programming language][golang]. It integrates well with Go's built-in `testing` package, but can be used in other contexts too. -## Installation +This project originates from Google's `golang/mock` repo. Unfortunately Google +no longer maintains this project, and given the heavy usage of gomock project +within Uber, we've decided to fork and maintain this going forward at Uber. -Once you have [installed Go][golang-install], install the `mockgen` tool. +Contributions are welcome in the form of GitHub issue or PR! -**Note**: If you have not done so already be sure to add `$GOPATH/bin` to your -`PATH`. +## Status -To get the latest released version use: +This project is still WIP. We will be tagging a release shortly, in early July. -### Go version < 1.16 +## Supported Go Versions -```bash -GO111MODULE=on go get github.com/golang/mock/mockgen@v1.6.0 -``` - -### Go 1.16+ - -```bash -go install github.com/golang/mock/mockgen@v1.6.0 -``` - -If you use `mockgen` in your CI pipeline, it may be more appropriate to fixate -on a specific mockgen version. You should try to keep the library in sync with -the version of mockgen used to generate your mocks. +go.uber.org/mock supports all Go versions supported by the official +[Go Release Policy](https://go.dev/doc/devel/release#policy). That is, +the two most recent releases of Go. ## Running mockgen @@ -250,28 +241,7 @@ If the received value is `3`, then it will be printed as `03`. [golang]: http://golang.org/ [golang-install]: http://golang.org/doc/install.html#releases -[gomock-reference]: https://pkg.go.dev/github.com/golang/mock/gomock -[ci-badge]: https://github.com/golang/mock/actions/workflows/test.yaml/badge.svg -[ci-runs]: https://github.com/golang/mock/actions -[reference-badge]: https://pkg.go.dev/badge/github.com/golang/mock.svg -[reference]: https://pkg.go.dev/github.com/golang/mock - -## Debugging Errors - -### reflect vendoring error - -```text -cannot find package "." -... github.com/golang/mock/mockgen/model -``` - -If you come across this error while using reflect mode and vendoring -dependencies there are three workarounds you can choose from: - -1. Use source mode. -2. Include an empty import `import _ "github.com/golang/mock/mockgen/model"`. -3. Add `--build_flags=--mod=mod` to your mockgen command. - -This error is due to changes in default behavior of the `go` command in more -recent versions. More details can be found in -[#494](https://github.com/golang/mock/issues/494). +[ci-badge]: https://github.com/uber/mock/actions/workflows/test.yaml/badge.svg +[ci-runs]: https://github.com/uber/mock/actions +[reference-badge]: https://pkg.go.dev/badge/github.com/uber/mock.svg +[reference]: https://pkg.go.dev/github.com/uber/mock diff --git a/go.mod b/go.mod index d920e36f..a2ccae15 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,14 @@ -module github.com/golang/mock +module go.uber.org/mock + +go 1.19 require ( golang.org/x/mod v0.5.1 golang.org/x/tools v0.1.8 ) -go 1.15 +require ( + github.com/yuin/goldmark v1.4.1 // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect +) diff --git a/go.sum b/go.sum index 5ae13f0c..62558136 100644 --- a/go.sum +++ b/go.sum @@ -1,29 +1,10 @@ github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/gomock/callset.go b/gomock/callset.go index 49dba787..f2131a14 100644 --- a/gomock/callset.go +++ b/gomock/callset.go @@ -18,15 +18,19 @@ import ( "bytes" "errors" "fmt" + "sync" ) // callSet represents a set of expected calls, indexed by receiver and method // name. type callSet struct { // Calls that are still expected. - expected map[callSetKey][]*Call + expected map[callSetKey][]*Call + expectedMu *sync.Mutex // Calls that have been exhausted. exhausted map[callSetKey][]*Call + // when set to true, existing call expectations are overridden when new call expectations are made + allowOverride bool } // callSetKey is the key in the maps in callSet @@ -36,22 +40,47 @@ type callSetKey struct { } func newCallSet() *callSet { - return &callSet{make(map[callSetKey][]*Call), make(map[callSetKey][]*Call)} + return &callSet{ + expected: make(map[callSetKey][]*Call), + expectedMu: &sync.Mutex{}, + exhausted: make(map[callSetKey][]*Call), + } +} + +func newOverridableCallSet() *callSet { + return &callSet{ + expected: make(map[callSetKey][]*Call), + expectedMu: &sync.Mutex{}, + exhausted: make(map[callSetKey][]*Call), + allowOverride: true, + } } // Add adds a new expected call. func (cs callSet) Add(call *Call) { key := callSetKey{call.receiver, call.method} + + cs.expectedMu.Lock() + defer cs.expectedMu.Unlock() + m := cs.expected if call.exhausted() { m = cs.exhausted } + if cs.allowOverride { + m[key] = make([]*Call, 0) + } + m[key] = append(m[key], call) } // Remove removes an expected call. func (cs callSet) Remove(call *Call) { key := callSetKey{call.receiver, call.method} + + cs.expectedMu.Lock() + defer cs.expectedMu.Unlock() + calls := cs.expected[key] for i, c := range calls { if c == call { @@ -67,6 +96,9 @@ func (cs callSet) Remove(call *Call) { func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) (*Call, error) { key := callSetKey{receiver, method} + cs.expectedMu.Lock() + defer cs.expectedMu.Unlock() + // Search through the expected calls. expected := cs.expected[key] var callsErrors bytes.Buffer @@ -101,6 +133,9 @@ func (cs callSet) FindMatch(receiver interface{}, method string, args []interfac // Failures returns the calls that are not satisfied. func (cs callSet) Failures() []*Call { + cs.expectedMu.Lock() + defer cs.expectedMu.Unlock() + failures := make([]*Call, 0, len(cs.expected)) for _, calls := range cs.expected { for _, call := range calls { @@ -111,3 +146,19 @@ func (cs callSet) Failures() []*Call { } return failures } + +// Satisfied returns true in case all expected calls in this callSet are satisfied. +func (cs callSet) Satisfied() bool { + cs.expectedMu.Lock() + defer cs.expectedMu.Unlock() + + for _, calls := range cs.expected { + for _, call := range calls { + if !call.satisfied() { + return false + } + } + } + + return true +} diff --git a/gomock/callset_test.go b/gomock/callset_test.go index fe053af7..74e2ce4e 100644 --- a/gomock/callset_test.go +++ b/gomock/callset_test.go @@ -42,6 +42,24 @@ func TestCallSetAdd(t *testing.T) { } } +func TestCallSetAdd_WhenOverridable_ClearsPreviousExpectedAndExhausted(t *testing.T) { + method := "TestMethod" + var receiver interface{} = "TestReceiver" + cs := newOverridableCallSet() + + cs.Add(newCall(t, receiver, method, reflect.TypeOf(receiverType{}.Func))) + numExpectedCalls := len(cs.expected[callSetKey{receiver, method}]) + if numExpectedCalls != 1 { + t.Fatalf("Expected 1 expected call in callset, got %d", numExpectedCalls) + } + + cs.Add(newCall(t, receiver, method, reflect.TypeOf(receiverType{}.Func))) + newNumExpectedCalls := len(cs.expected[callSetKey{receiver, method}]) + if newNumExpectedCalls != 1 { + t.Fatalf("Expected 1 expected call in callset, got %d", newNumExpectedCalls) + } +} + func TestCallSetRemove(t *testing.T) { method := "TestMethod" var receiver interface{} = "TestReceiver" @@ -77,7 +95,7 @@ func TestCallSetRemove(t *testing.T) { func TestCallSetFindMatch(t *testing.T) { t.Run("call is exhausted", func(t *testing.T) { - cs := callSet{} + cs := newCallSet() var receiver interface{} = "TestReceiver" method := "TestMethod" args := []interface{}{} diff --git a/gomock/controller.go b/gomock/controller.go index 5e2def13..de904c8c 100644 --- a/gomock/controller.go +++ b/gomock/controller.go @@ -51,24 +51,24 @@ type cleanuper interface { // goroutines. Each test should create a new Controller and invoke Finish via // defer. // -// func TestFoo(t *testing.T) { -// ctrl := gomock.NewController(t) -// defer ctrl.Finish() -// // .. -// } +// func TestFoo(t *testing.T) { +// ctrl := gomock.NewController(t) +// defer ctrl.Finish() +// // .. +// } // -// func TestBar(t *testing.T) { -// t.Run("Sub-Test-1", st) { -// ctrl := gomock.NewController(st) -// defer ctrl.Finish() -// // .. -// }) -// t.Run("Sub-Test-2", st) { -// ctrl := gomock.NewController(st) -// defer ctrl.Finish() -// // .. -// }) -// }) +// func TestBar(t *testing.T) { +// t.Run("Sub-Test-1", st) { +// ctrl := gomock.NewController(st) +// defer ctrl.Finish() +// // .. +// }) +// t.Run("Sub-Test-2", st) { +// ctrl := gomock.NewController(st) +// defer ctrl.Finish() +// // .. +// }) +// }) type Controller struct { // T should only be called within a generated mock. It is not intended to // be used in user code and may be changed in future versions. T is the @@ -86,7 +86,7 @@ type Controller struct { // // New in go1.14+, if you are passing a *testing.T into this function you no // longer need to call ctrl.Finish() in your test methods. -func NewController(t TestReporter) *Controller { +func NewController(t TestReporter, opts ...ControllerOption) *Controller { h, ok := t.(TestHelper) if !ok { h = &nopTestHelper{t} @@ -95,6 +95,9 @@ func NewController(t TestReporter) *Controller { T: h, expectedCalls: newCallSet(), } + for _, opt := range opts { + opt.apply(ctrl) + } if c, ok := isCleanuper(ctrl.T); ok { c.Cleanup(func() { ctrl.T.Helper() @@ -105,6 +108,23 @@ func NewController(t TestReporter) *Controller { return ctrl } +// ControllerOption configures how a Controller should behave. +type ControllerOption interface { + apply(*Controller) +} + +type overridableExpectationsOption struct{} + +// WithOverridableExpectations allows for overridable call expectations +// i.e., subsequent call expectations override existing call expectations +func WithOverridableExpectations() overridableExpectationsOption { + return overridableExpectationsOption{} +} + +func (o overridableExpectationsOption) apply(ctrl *Controller) { + ctrl.expectedCalls = newOverridableCallSet() +} + type cancelReporter struct { t TestHelper cancel func() @@ -231,6 +251,12 @@ func (ctrl *Controller) Finish() { ctrl.finish(false, err) } +// Satisfied returns whether all expected calls bound to this Controller have been satisfied. +// Calling Finish is then guaranteed to not fail due to missing calls. +func (ctrl *Controller) Satisfied() bool { + return ctrl.expectedCalls.Satisfied() +} + func (ctrl *Controller) finish(cleanup bool, panicErr interface{}) { ctrl.T.Helper() diff --git a/gomock/controller_test.go b/gomock/controller_test.go index 921a51f8..69477238 100644 --- a/gomock/controller_test.go +++ b/gomock/controller_test.go @@ -21,7 +21,7 @@ import ( "strings" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) type ErrorReporter struct { diff --git a/gomock/doc.go b/gomock/doc.go index 1706b504..f1a304fb 100644 --- a/gomock/doc.go +++ b/gomock/doc.go @@ -15,18 +15,19 @@ // Package gomock is a mock framework for Go. // // Standard usage: -// (1) Define an interface that you wish to mock. -// type MyInterface interface { -// SomeMethod(x int64, y string) -// } -// (2) Use mockgen to generate a mock from the interface. -// (3) Use the mock in a test: -// func TestMyThing(t *testing.T) { -// mockCtrl := gomock.NewController(t)// -// mockObj := something.NewMockMyInterface(mockCtrl) -// mockObj.EXPECT().SomeMethod(4, "blah") -// // pass mockObj to a real object and play with it. -// } +// +// (1) Define an interface that you wish to mock. +// type MyInterface interface { +// SomeMethod(x int64, y string) +// } +// (2) Use mockgen to generate a mock from the interface. +// (3) Use the mock in a test: +// func TestMyThing(t *testing.T) { +// mockCtrl := gomock.NewController(t)// +// mockObj := something.NewMockMyInterface(mockCtrl) +// mockObj.EXPECT().SomeMethod(4, "blah") +// // pass mockObj to a real object and play with it. +// } // // By default, expected calls are not enforced to run in any particular order. // Call order dependency can be enforced by use of InOrder and/or Call.After. @@ -37,17 +38,17 @@ // // Example of using Call.After to chain expected call order: // -// firstCall := mockObj.EXPECT().SomeMethod(1, "first") -// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall) -// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall) +// firstCall := mockObj.EXPECT().SomeMethod(1, "first") +// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall) +// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall) // // Example of using InOrder to declare expected call order: // -// gomock.InOrder( -// mockObj.EXPECT().SomeMethod(1, "first"), -// mockObj.EXPECT().SomeMethod(2, "second"), -// mockObj.EXPECT().SomeMethod(3, "third"), -// ) +// gomock.InOrder( +// mockObj.EXPECT().SomeMethod(1, "first"), +// mockObj.EXPECT().SomeMethod(2, "second"), +// mockObj.EXPECT().SomeMethod(3, "third"), +// ) // // The standard TestReporter most users will pass to `NewController` is a // `*testing.T` from the context of the test. Note that this will use the diff --git a/gomock/example_test.go b/gomock/example_test.go index 0d938847..25b20a2e 100644 --- a/gomock/example_test.go +++ b/gomock/example_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) type Foo interface { @@ -48,3 +48,21 @@ func ExampleCall_DoAndReturn_captureArguments() { fmt.Printf("%s %s", r, s) // Output: I'm sleepy foo } + +func ExampleCall_DoAndReturn_withOverridableExpectations() { + t := &testing.T{} // provided by test + ctrl := gomock.NewController(t, gomock.WithOverridableExpectations()) + mockIndex := NewMockFoo(ctrl) + var s string + + mockIndex.EXPECT().Bar(gomock.AssignableToTypeOf(s)).DoAndReturn( + func(arg string) interface{} { + s = arg + return "I'm sleepy" + }, + ) + + r := mockIndex.Bar("foo") + fmt.Printf("%s %s", r, s) + // Output: I'm sleepy foo +} diff --git a/gomock/internal/mock_gomock/mock_matcher.go b/gomock/internal/mock_gomock/mock_matcher.go index f4a6d526..6ba1f204 100644 --- a/gomock/internal/mock_gomock/mock_matcher.go +++ b/gomock/internal/mock_gomock/mock_matcher.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/gomock (interfaces: Matcher) +// Source: go.uber.org/mock/gomock (interfaces: Matcher) // Package mock_gomock is a generated GoMock package. package mock_gomock @@ -7,7 +7,7 @@ package mock_gomock import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockMatcher is a mock of Matcher interface. diff --git a/gomock/matchers.go b/gomock/matchers.go index 2822fb2c..6d5eff4f 100644 --- a/gomock/matchers.go +++ b/gomock/matchers.go @@ -283,8 +283,9 @@ func Any() Matcher { return anyMatcher{} } // Eq returns a matcher that matches on equality. // // Example usage: -// Eq(5).Matches(5) // returns true -// Eq(5).Matches(4) // returns false +// +// Eq(5).Matches(5) // returns true +// Eq(5).Matches(4) // returns false func Eq(x interface{}) Matcher { return eqMatcher{x} } // Len returns a matcher that matches on length. This matcher returns false if @@ -296,17 +297,19 @@ func Len(i int) Matcher { // Nil returns a matcher that matches if the received value is nil. // // Example usage: -// var x *bytes.Buffer -// Nil().Matches(x) // returns true -// x = &bytes.Buffer{} -// Nil().Matches(x) // returns false +// +// var x *bytes.Buffer +// Nil().Matches(x) // returns true +// x = &bytes.Buffer{} +// Nil().Matches(x) // returns false func Nil() Matcher { return nilMatcher{} } // Not reverses the results of its given child matcher. // // Example usage: -// Not(Eq(5)).Matches(4) // returns true -// Not(Eq(5)).Matches(5) // returns false +// +// Not(Eq(5)).Matches(4) // returns true +// Not(Eq(5)).Matches(5) // returns false func Not(x interface{}) Matcher { if m, ok := x.(Matcher); ok { return notMatcher{m} @@ -318,12 +321,13 @@ func Not(x interface{}) Matcher { // function is assignable to the type of the parameter to this function. // // Example usage: -// var s fmt.Stringer = &bytes.Buffer{} -// AssignableToTypeOf(s).Matches(time.Second) // returns true -// AssignableToTypeOf(s).Matches(99) // returns false // -// var ctx = reflect.TypeOf((*context.Context)(nil)).Elem() -// AssignableToTypeOf(ctx).Matches(context.Background()) // returns true +// var s fmt.Stringer = &bytes.Buffer{} +// AssignableToTypeOf(s).Matches(time.Second) // returns true +// AssignableToTypeOf(s).Matches(99) // returns false +// +// var ctx = reflect.TypeOf((*context.Context)(nil)).Elem() +// AssignableToTypeOf(ctx).Matches(context.Background()) // returns true func AssignableToTypeOf(x interface{}) Matcher { if xt, ok := x.(reflect.Type); ok { return assignableToTypeOfMatcher{xt} @@ -334,8 +338,9 @@ func AssignableToTypeOf(x interface{}) Matcher { // InAnyOrder is a Matcher that returns true for collections of the same elements ignoring the order. // // Example usage: -// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true -// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false +// +// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true +// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false func InAnyOrder(x interface{}) Matcher { return inAnyOrderMatcher{x} } diff --git a/gomock/matchers_test.go b/gomock/matchers_test.go index 61bc1993..5868c407 100644 --- a/gomock/matchers_test.go +++ b/gomock/matchers_test.go @@ -14,7 +14,7 @@ package gomock_test -//go:generate mockgen -destination internal/mock_gomock/mock_matcher.go github.com/golang/mock/gomock Matcher +//go:generate mockgen -destination internal/mock_gomock/mock_matcher.go go.uber.org/mock/gomock Matcher import ( "context" @@ -22,8 +22,8 @@ import ( "reflect" "testing" - "github.com/golang/mock/gomock" - "github.com/golang/mock/gomock/internal/mock_gomock" + "go.uber.org/mock/gomock" + "go.uber.org/mock/gomock/internal/mock_gomock" ) type A []string diff --git a/gomock/mock_test.go b/gomock/mock_test.go index 4f1cfa91..03c5fd1b 100644 --- a/gomock/mock_test.go +++ b/gomock/mock_test.go @@ -7,7 +7,7 @@ package gomock_test import ( reflect "reflect" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) // MockFoo is a mock of Foo interface. diff --git a/gomock/overridable_controller_test.go b/gomock/overridable_controller_test.go new file mode 100644 index 00000000..3d75e6af --- /dev/null +++ b/gomock/overridable_controller_test.go @@ -0,0 +1,34 @@ +package gomock_test + +import ( + "testing" + + "go.uber.org/mock/gomock" +) + +func TestEcho_NoOverride(t *testing.T) { + ctrl := gomock.NewController(t, gomock.WithOverridableExpectations()) + mockIndex := NewMockFoo(ctrl) + + mockIndex.EXPECT().Bar(gomock.Any()).Return("foo") + res := mockIndex.Bar("input") + + if res != "foo" { + t.Fatalf("expected response to equal 'foo', got %s", res) + } +} + +func TestEcho_WithOverride_BaseCase(t *testing.T) { + ctrl := gomock.NewController(t, gomock.WithOverridableExpectations()) + mockIndex := NewMockFoo(ctrl) + + // initial expectation set + mockIndex.EXPECT().Bar(gomock.Any()).Return("foo") + // override + mockIndex.EXPECT().Bar(gomock.Any()).Return("bar") + res := mockIndex.Bar("input") + + if res != "bar" { + t.Fatalf("expected response to equal 'bar', got %s", res) + } +} diff --git a/mockgen/generic_go118.go b/mockgen/generic_go118.go index b29db9a8..917a15e8 100644 --- a/mockgen/generic_go118.go +++ b/mockgen/generic_go118.go @@ -14,7 +14,7 @@ import ( "go/ast" "strings" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" ) func getTypeSpecTypeParams(ts *ast.TypeSpec) []*ast.Field { diff --git a/mockgen/generic_notgo118.go b/mockgen/generic_notgo118.go index 8fe48c17..b608438c 100644 --- a/mockgen/generic_notgo118.go +++ b/mockgen/generic_notgo118.go @@ -20,7 +20,7 @@ package main import ( "go/ast" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" ) func getTypeSpecTypeParams(ts *ast.TypeSpec) []*ast.Field { diff --git a/mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go b/mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go index 288ab5d9..f49532df 100644 --- a/mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go +++ b/mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go @@ -5,7 +5,7 @@ package bugreport import ( "log" - "github.com/golang/mock/mockgen/internal/tests/aux_imports_embedded_interface/faux" + "go.uber.org/mock/mockgen/internal/tests/aux_imports_embedded_interface/faux" ) // Source is an interface w/ an embedded foreign interface diff --git a/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go b/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go index 26a80d65..ea51e2ae 100644 --- a/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go +++ b/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go @@ -7,8 +7,8 @@ package bugreport import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - faux "github.com/golang/mock/mockgen/internal/tests/aux_imports_embedded_interface/faux" + gomock "go.uber.org/mock/gomock" + faux "go.uber.org/mock/mockgen/internal/tests/aux_imports_embedded_interface/faux" ) // MockSource is a mock of Source interface. diff --git a/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go b/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go index acfca322..cef03ed0 100644 --- a/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go +++ b/mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go @@ -3,7 +3,7 @@ package bugreport import ( "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) // TestValidInterface assesses whether or not the generated mock is valid diff --git a/mockgen/internal/tests/const_array_length/mock.go b/mockgen/internal/tests/const_array_length/mock.go index 2591361c..b39fe8c1 100644 --- a/mockgen/internal/tests/const_array_length/mock.go +++ b/mockgen/internal/tests/const_array_length/mock.go @@ -7,7 +7,7 @@ package const_length import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockI is a mock of I interface. diff --git a/mockgen/internal/tests/copyright_file/mock.go b/mockgen/internal/tests/copyright_file/mock.go index 3cfabcfa..cb773191 100644 --- a/mockgen/internal/tests/copyright_file/mock.go +++ b/mockgen/internal/tests/copyright_file/mock.go @@ -12,7 +12,7 @@ package empty_interface import ( - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockEmpty is a mock of Empty interface. diff --git a/mockgen/internal/tests/custom_package_name/greeter/greeter.go b/mockgen/internal/tests/custom_package_name/greeter/greeter.go index fd2eee0b..7bb4d99b 100644 --- a/mockgen/internal/tests/custom_package_name/greeter/greeter.go +++ b/mockgen/internal/tests/custom_package_name/greeter/greeter.go @@ -7,10 +7,10 @@ import ( "fmt" // non-matching import suffix and package name - "github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1" + "go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1" // matching import suffix and package name - "github.com/golang/mock/mockgen/internal/tests/custom_package_name/validator" + "go.uber.org/mock/mockgen/internal/tests/custom_package_name/validator" ) type InputMaker interface { diff --git a/mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go b/mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go index c0fe30c2..2b020ebb 100644 --- a/mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go +++ b/mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go @@ -7,8 +7,8 @@ package greeter import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - client "github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1" + gomock "go.uber.org/mock/gomock" + client "go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1" ) // MockInputMaker is a mock of InputMaker interface. diff --git a/mockgen/internal/tests/custom_package_name/greeter/greeter_test.go b/mockgen/internal/tests/custom_package_name/greeter/greeter_test.go index a64d677c..b34d05fb 100644 --- a/mockgen/internal/tests/custom_package_name/greeter/greeter_test.go +++ b/mockgen/internal/tests/custom_package_name/greeter/greeter_test.go @@ -3,8 +3,8 @@ package greeter import ( "testing" - "github.com/golang/mock/gomock" - "github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1" + "go.uber.org/mock/gomock" + "go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1" ) func TestGreeter_Greet(t *testing.T) { diff --git a/mockgen/internal/tests/dot_imports/mock.go b/mockgen/internal/tests/dot_imports/mock.go index 6e46eab9..dffee9dd 100644 --- a/mockgen/internal/tests/dot_imports/mock.go +++ b/mockgen/internal/tests/dot_imports/mock.go @@ -10,7 +10,7 @@ import ( . "net/http" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockWithDotImports is a mock of WithDotImports interface. diff --git a/mockgen/internal/tests/empty_interface/mock.go b/mockgen/internal/tests/empty_interface/mock.go index bffcf8ea..13b9f30c 100644 --- a/mockgen/internal/tests/empty_interface/mock.go +++ b/mockgen/internal/tests/empty_interface/mock.go @@ -5,7 +5,7 @@ package empty_interface import ( - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockEmpty is a mock of Empty interface. diff --git a/mockgen/internal/tests/extra_import/mock.go b/mockgen/internal/tests/extra_import/mock.go index d8b0928e..d3f6c530 100644 --- a/mockgen/internal/tests/extra_import/mock.go +++ b/mockgen/internal/tests/extra_import/mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/mockgen/internal/tests/extra_import (interfaces: Foo) +// Source: go.uber.org/mock/mockgen/internal/tests/extra_import (interfaces: Foo) // Package extra_import is a generated GoMock package. package extra_import @@ -7,7 +7,7 @@ package extra_import import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockFoo is a mock of Foo interface. diff --git a/mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go b/mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go index 8eca8644..e1882739 100644 --- a/mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go +++ b/mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go @@ -7,7 +7,7 @@ package bugreport import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockExample is a mock of Example interface. diff --git a/mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go b/mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go index 3ca9807d..3b53248a 100644 --- a/mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go +++ b/mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go @@ -1,7 +1,7 @@ package bugreport import ( - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" "testing" ) diff --git a/mockgen/internal/tests/generics/external.go b/mockgen/internal/tests/generics/external.go index ec5032aa..68b2d4b3 100644 --- a/mockgen/internal/tests/generics/external.go +++ b/mockgen/internal/tests/generics/external.go @@ -1,7 +1,7 @@ package generics import ( - "github.com/golang/mock/mockgen/internal/tests/generics/other" + "go.uber.org/mock/mockgen/internal/tests/generics/other" "golang.org/x/exp/constraints" ) diff --git a/mockgen/internal/tests/generics/generics.go b/mockgen/internal/tests/generics/generics.go index 0b389622..647a6fca 100644 --- a/mockgen/internal/tests/generics/generics.go +++ b/mockgen/internal/tests/generics/generics.go @@ -1,6 +1,6 @@ package generics -import "github.com/golang/mock/mockgen/internal/tests/generics/other" +import "go.uber.org/mock/mockgen/internal/tests/generics/other" //go:generate mockgen --source=generics.go --destination=source/mock_generics_test.go --package source ////go:generate mockgen --destination=reflect/mock_test.go --package reflect . Bar,Bar2 diff --git a/mockgen/internal/tests/generics/go.mod b/mockgen/internal/tests/generics/go.mod index 7eb82e14..01224450 100644 --- a/mockgen/internal/tests/generics/go.mod +++ b/mockgen/internal/tests/generics/go.mod @@ -1,10 +1,10 @@ -module github.com/golang/mock/mockgen/internal/tests/generics +module go.uber.org/mock/mockgen/internal/tests/generics -go 1.18 +go 1.19 require ( - github.com/golang/mock v1.6.0 + go.uber.org/mock v1.6.0 golang.org/x/exp v0.0.0-20220428152302-39d4317da171 ) -replace github.com/golang/mock => ../../../.. +replace go.uber.org/mock => ../../../.. diff --git a/mockgen/internal/tests/generics/go.sum b/mockgen/internal/tests/generics/go.sum index c6f44641..698ce9bc 100644 --- a/mockgen/internal/tests/generics/go.sum +++ b/mockgen/internal/tests/generics/go.sum @@ -1,26 +1,2 @@ -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4= golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/mockgen/internal/tests/generics/source/mock_external_test.go b/mockgen/internal/tests/generics/source/mock_external_test.go index aab22749..32a876b8 100644 --- a/mockgen/internal/tests/generics/source/mock_external_test.go +++ b/mockgen/internal/tests/generics/source/mock_external_test.go @@ -7,9 +7,9 @@ package source import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - generics "github.com/golang/mock/mockgen/internal/tests/generics" - other "github.com/golang/mock/mockgen/internal/tests/generics/other" + gomock "go.uber.org/mock/gomock" + generics "go.uber.org/mock/mockgen/internal/tests/generics" + other "go.uber.org/mock/mockgen/internal/tests/generics/other" constraints "golang.org/x/exp/constraints" ) diff --git a/mockgen/internal/tests/generics/source/mock_generics_test.go b/mockgen/internal/tests/generics/source/mock_generics_test.go index 0223e311..ad343407 100644 --- a/mockgen/internal/tests/generics/source/mock_generics_test.go +++ b/mockgen/internal/tests/generics/source/mock_generics_test.go @@ -7,9 +7,9 @@ package source import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - generics "github.com/golang/mock/mockgen/internal/tests/generics" - other "github.com/golang/mock/mockgen/internal/tests/generics/other" + gomock "go.uber.org/mock/gomock" + generics "go.uber.org/mock/mockgen/internal/tests/generics" + other "go.uber.org/mock/mockgen/internal/tests/generics/other" ) // MockBar is a mock of Bar interface. diff --git a/mockgen/internal/tests/import_embedded_interface/bugreport.go b/mockgen/internal/tests/import_embedded_interface/bugreport.go index 798d138e..0fedd7ef 100644 --- a/mockgen/internal/tests/import_embedded_interface/bugreport.go +++ b/mockgen/internal/tests/import_embedded_interface/bugreport.go @@ -19,8 +19,8 @@ package bugreport import ( "log" - "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/ersatz" - "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/faux" + "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/ersatz" + "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/faux" ) // Source is an interface w/ an embedded foreign interface diff --git a/mockgen/internal/tests/import_embedded_interface/bugreport_mock.go b/mockgen/internal/tests/import_embedded_interface/bugreport_mock.go index c060f8eb..2c482f57 100644 --- a/mockgen/internal/tests/import_embedded_interface/bugreport_mock.go +++ b/mockgen/internal/tests/import_embedded_interface/bugreport_mock.go @@ -7,9 +7,9 @@ package bugreport import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - ersatz "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/ersatz" - ersatz0 "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz" + gomock "go.uber.org/mock/gomock" + ersatz "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/ersatz" + ersatz0 "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz" ) // MockSource is a mock of Source interface. diff --git a/mockgen/internal/tests/import_embedded_interface/bugreport_test.go b/mockgen/internal/tests/import_embedded_interface/bugreport_test.go index 5915cbe1..27678408 100644 --- a/mockgen/internal/tests/import_embedded_interface/bugreport_test.go +++ b/mockgen/internal/tests/import_embedded_interface/bugreport_test.go @@ -11,12 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package bugreport import ( "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) // TestValidInterface assesses whether or not the generated mock is valid diff --git a/mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go b/mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go index 0d2c7815..be01bb41 100644 --- a/mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go +++ b/mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package ersatz type Embedded interface { diff --git a/mockgen/internal/tests/import_embedded_interface/faux/conflict.go b/mockgen/internal/tests/import_embedded_interface/faux/conflict.go index 27803dd6..5fcf9c1a 100644 --- a/mockgen/internal/tests/import_embedded_interface/faux/conflict.go +++ b/mockgen/internal/tests/import_embedded_interface/faux/conflict.go @@ -11,9 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package faux -import "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/log" +import "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/other/log" func Conflict1() { log.Foo() diff --git a/mockgen/internal/tests/import_embedded_interface/faux/faux.go b/mockgen/internal/tests/import_embedded_interface/faux/faux.go index e1d66988..db3d1554 100644 --- a/mockgen/internal/tests/import_embedded_interface/faux/faux.go +++ b/mockgen/internal/tests/import_embedded_interface/faux/faux.go @@ -11,12 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package faux import ( "log" - "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz" + "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz" ) type Foreign interface { diff --git a/mockgen/internal/tests/import_embedded_interface/net_mock.go b/mockgen/internal/tests/import_embedded_interface/net_mock.go index 07792a6d..401529de 100644 --- a/mockgen/internal/tests/import_embedded_interface/net_mock.go +++ b/mockgen/internal/tests/import_embedded_interface/net_mock.go @@ -8,7 +8,7 @@ import ( http "net/http" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockNet is a mock of Net interface. diff --git a/mockgen/internal/tests/import_embedded_interface/net_test.go b/mockgen/internal/tests/import_embedded_interface/net_test.go index 381f7de3..bf98dd80 100644 --- a/mockgen/internal/tests/import_embedded_interface/net_test.go +++ b/mockgen/internal/tests/import_embedded_interface/net_test.go @@ -11,12 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package bugreport import ( "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) // TestValidInterface assesses whether or not the generated mock is valid diff --git a/mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go b/mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go index 9ca63914..25815d61 100644 --- a/mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go +++ b/mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package ersatz type Embedded interface { diff --git a/mockgen/internal/tests/import_embedded_interface/other/log/log.go b/mockgen/internal/tests/import_embedded_interface/other/log/log.go index c0d032bf..469ba319 100644 --- a/mockgen/internal/tests/import_embedded_interface/other/log/log.go +++ b/mockgen/internal/tests/import_embedded_interface/other/log/log.go @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + package log func Foo() {} diff --git a/mockgen/internal/tests/import_source/definition/source_mock.go b/mockgen/internal/tests/import_source/definition/source_mock.go index b3d58d76..52a1be6a 100644 --- a/mockgen/internal/tests/import_source/definition/source_mock.go +++ b/mockgen/internal/tests/import_source/definition/source_mock.go @@ -7,7 +7,7 @@ package source import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockS is a mock of S interface. diff --git a/mockgen/internal/tests/import_source/source_mock.go b/mockgen/internal/tests/import_source/source_mock.go index 46677a31..1309a43c 100644 --- a/mockgen/internal/tests/import_source/source_mock.go +++ b/mockgen/internal/tests/import_source/source_mock.go @@ -7,8 +7,8 @@ package mock_source import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - source "github.com/golang/mock/mockgen/internal/tests/import_source/definition" + gomock "go.uber.org/mock/gomock" + source "go.uber.org/mock/mockgen/internal/tests/import_source/definition" ) // MockS is a mock of S interface. diff --git a/mockgen/internal/tests/internal_pkg/generate.go b/mockgen/internal/tests/internal_pkg/generate.go index 4e0a0cca..3e3e17fb 100644 --- a/mockgen/internal/tests/internal_pkg/generate.go +++ b/mockgen/internal/tests/internal_pkg/generate.go @@ -1,4 +1,4 @@ package test -//go:generate mockgen -destination subdir/internal/pkg/reflect_output/mock.go github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg Intf +//go:generate mockgen -destination subdir/internal/pkg/reflect_output/mock.go go.uber.org/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg Intf //go:generate mockgen -source subdir/internal/pkg/input.go -destination subdir/internal/pkg/source_output/mock.go diff --git a/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go b/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go index 967c4b59..76892c1d 100644 --- a/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go +++ b/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg (interfaces: Intf) +// Source: go.uber.org/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg (interfaces: Intf) // Package mock_pkg is a generated GoMock package. package mock_pkg @@ -7,8 +7,8 @@ package mock_pkg import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - pkg "github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg" + gomock "go.uber.org/mock/gomock" + pkg "go.uber.org/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg" ) // MockIntf is a mock of Intf interface. diff --git a/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go b/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go index 2e61bae4..3cf24f83 100644 --- a/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go +++ b/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go @@ -7,8 +7,8 @@ package mock_pkg import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - pkg "github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg" + gomock "go.uber.org/mock/gomock" + pkg "go.uber.org/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg" ) // MockArg is a mock of Arg interface. diff --git a/mockgen/internal/tests/missing_import/output/source_mock.go b/mockgen/internal/tests/missing_import/output/source_mock.go index 082d10bc..34f979de 100644 --- a/mockgen/internal/tests/missing_import/output/source_mock.go +++ b/mockgen/internal/tests/missing_import/output/source_mock.go @@ -7,8 +7,8 @@ package source import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - source "github.com/golang/mock/mockgen/internal/tests/missing_import/source" + gomock "go.uber.org/mock/gomock" + source "go.uber.org/mock/mockgen/internal/tests/missing_import/source" ) // MockBar is a mock of Bar interface. diff --git a/mockgen/internal/tests/mock_in_test_package/mock_test.go b/mockgen/internal/tests/mock_in_test_package/mock_test.go index 08bc27b0..13fc8120 100644 --- a/mockgen/internal/tests/mock_in_test_package/mock_test.go +++ b/mockgen/internal/tests/mock_in_test_package/mock_test.go @@ -7,8 +7,8 @@ package users_test import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" - users "github.com/golang/mock/mockgen/internal/tests/mock_in_test_package" + gomock "go.uber.org/mock/gomock" + users "go.uber.org/mock/mockgen/internal/tests/mock_in_test_package" ) // MockFinder is a mock of Finder interface. diff --git a/mockgen/internal/tests/overlapping_methods/mock.go b/mockgen/internal/tests/overlapping_methods/mock.go index 20cbc397..1882380a 100644 --- a/mockgen/internal/tests/overlapping_methods/mock.go +++ b/mockgen/internal/tests/overlapping_methods/mock.go @@ -7,7 +7,7 @@ package overlap import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockReadWriteCloser is a mock of ReadWriteCloser interface. diff --git a/mockgen/internal/tests/overlapping_methods/overlap.go b/mockgen/internal/tests/overlapping_methods/overlap.go index 82ff012e..b2625b14 100644 --- a/mockgen/internal/tests/overlapping_methods/overlap.go +++ b/mockgen/internal/tests/overlapping_methods/overlap.go @@ -1,6 +1,6 @@ package overlap -//go:generate mockgen -package overlap -destination mock.go -source overlap.go -aux_files github.com/golang/mock/mockgen/internal/tests/overlapping_methods=interfaces.go +//go:generate mockgen -package overlap -destination mock.go -source overlap.go -aux_files go.uber.org/mock/mockgen/internal/tests/overlapping_methods=interfaces.go type ReadWriteCloser interface { ReadCloser diff --git a/mockgen/internal/tests/overlapping_methods/overlap_test.go b/mockgen/internal/tests/overlapping_methods/overlap_test.go index fdd9ba73..0bb8a3dd 100644 --- a/mockgen/internal/tests/overlapping_methods/overlap_test.go +++ b/mockgen/internal/tests/overlapping_methods/overlap_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // TestValidInterface assesses whether or not the generated mock is valid diff --git a/mockgen/internal/tests/panicing_test/mock_test.go b/mockgen/internal/tests/panicing_test/mock_test.go index 5c7ef668..265227b1 100644 --- a/mockgen/internal/tests/panicing_test/mock_test.go +++ b/mockgen/internal/tests/panicing_test/mock_test.go @@ -7,7 +7,7 @@ package paniccode import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockFoo is a mock of Foo interface. diff --git a/mockgen/internal/tests/panicing_test/panic_test.go b/mockgen/internal/tests/panicing_test/panic_test.go index 3e630f34..436ce8e3 100644 --- a/mockgen/internal/tests/panicing_test/panic_test.go +++ b/mockgen/internal/tests/panicing_test/panic_test.go @@ -20,7 +20,7 @@ package paniccode import ( "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) func TestDanger_Panics_Explicit(t *testing.T) { diff --git a/mockgen/internal/tests/parenthesized_parameter_type/mock.go b/mockgen/internal/tests/parenthesized_parameter_type/mock.go index 911df8d8..ff4fc309 100644 --- a/mockgen/internal/tests/parenthesized_parameter_type/mock.go +++ b/mockgen/internal/tests/parenthesized_parameter_type/mock.go @@ -5,7 +5,7 @@ package parenthesized_parameter_type import ( - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" reflect "reflect" ) diff --git a/mockgen/internal/tests/self_package/mock.go b/mockgen/internal/tests/self_package/mock.go index 72e2cfa8..66004296 100644 --- a/mockgen/internal/tests/self_package/mock.go +++ b/mockgen/internal/tests/self_package/mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/mockgen/internal/tests/self_package (interfaces: Methods) +// Source: go.uber.org/mock/mockgen/internal/tests/self_package (interfaces: Methods) // Package core is a generated GoMock package. package core @@ -7,7 +7,7 @@ package core import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockMethods is a mock of Methods interface. diff --git a/mockgen/internal/tests/self_package/types.go b/mockgen/internal/tests/self_package/types.go index bf1bc766..9cc8630f 100644 --- a/mockgen/internal/tests/self_package/types.go +++ b/mockgen/internal/tests/self_package/types.go @@ -1,6 +1,6 @@ package core -//go:generate mockgen -package core -self_package github.com/golang/mock/mockgen/internal/tests/self_package -destination mock.go github.com/golang/mock/mockgen/internal/tests/self_package Methods +//go:generate mockgen -package core -self_package go.uber.org/mock/mockgen/internal/tests/self_package -destination mock.go go.uber.org/mock/mockgen/internal/tests/self_package Methods type Info struct{} diff --git a/mockgen/internal/tests/test_package/mock_test.go b/mockgen/internal/tests/test_package/mock_test.go index b357165b..05e66d29 100644 --- a/mockgen/internal/tests/test_package/mock_test.go +++ b/mockgen/internal/tests/test_package/mock_test.go @@ -7,7 +7,7 @@ package users_test import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockFinder is a mock of Finder interface. diff --git a/mockgen/internal/tests/unexported_method/bugreport_mock.go b/mockgen/internal/tests/unexported_method/bugreport_mock.go index d52d06ec..305902e4 100644 --- a/mockgen/internal/tests/unexported_method/bugreport_mock.go +++ b/mockgen/internal/tests/unexported_method/bugreport_mock.go @@ -7,7 +7,7 @@ package bugreport import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockExample is a mock of Example interface. diff --git a/mockgen/internal/tests/unexported_method/bugreport_test.go b/mockgen/internal/tests/unexported_method/bugreport_test.go index d428fb4c..b3286852 100644 --- a/mockgen/internal/tests/unexported_method/bugreport_test.go +++ b/mockgen/internal/tests/unexported_method/bugreport_test.go @@ -3,7 +3,7 @@ package bugreport import ( "testing" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" ) func TestCallExample(t *testing.T) { diff --git a/mockgen/internal/tests/vendor_dep/doc.go b/mockgen/internal/tests/vendor_dep/doc.go index 29e424c8..de3e785e 100644 --- a/mockgen/internal/tests/vendor_dep/doc.go +++ b/mockgen/internal/tests/vendor_dep/doc.go @@ -1,4 +1,4 @@ package vendor_dep -//go:generate mockgen -package vendor_dep -destination mock.go github.com/golang/mock/mockgen/internal/tests/vendor_dep VendorsDep +//go:generate mockgen -package vendor_dep -destination mock.go go.uber.org/mock/mockgen/internal/tests/vendor_dep VendorsDep //go:generate mockgen -destination source_mock_package/mock.go -source=vendor_dep.go diff --git a/mockgen/internal/tests/vendor_dep/mock.go b/mockgen/internal/tests/vendor_dep/mock.go index 4900ac08..62c55c63 100644 --- a/mockgen/internal/tests/vendor_dep/mock.go +++ b/mockgen/internal/tests/vendor_dep/mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/mockgen/internal/tests/vendor_dep (interfaces: VendorsDep) +// Source: go.uber.org/mock/mockgen/internal/tests/vendor_dep (interfaces: VendorsDep) // Package vendor_dep is a generated GoMock package. package vendor_dep @@ -7,7 +7,7 @@ package vendor_dep import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" present "golang.org/x/tools/present" ) diff --git a/mockgen/internal/tests/vendor_dep/source_mock_package/mock.go b/mockgen/internal/tests/vendor_dep/source_mock_package/mock.go index b02a0489..c3f76d79 100644 --- a/mockgen/internal/tests/vendor_dep/source_mock_package/mock.go +++ b/mockgen/internal/tests/vendor_dep/source_mock_package/mock.go @@ -7,7 +7,7 @@ package mock_vendor_dep import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" present "golang.org/x/tools/present" ) diff --git a/mockgen/internal/tests/vendor_pkg/mock.go b/mockgen/internal/tests/vendor_pkg/mock.go index f0a41968..53cc47d1 100644 --- a/mockgen/internal/tests/vendor_pkg/mock.go +++ b/mockgen/internal/tests/vendor_pkg/mock.go @@ -7,7 +7,7 @@ package vendor_pkg import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockElem is a mock of Elem interface. diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go index 79cb921c..031b4eaa 100644 --- a/mockgen/mockgen.go +++ b/mockgen/mockgen.go @@ -37,14 +37,14 @@ import ( "strings" "unicode" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" "golang.org/x/mod/modfile" toolsimports "golang.org/x/tools/imports" ) const ( - gomockImportPath = "github.com/golang/mock/gomock" + gomockImportPath = "go.uber.org/mock/gomock" ) var ( diff --git a/mockgen/mockgen_test.go b/mockgen/mockgen_test.go index 55566001..58209471 100644 --- a/mockgen/mockgen_test.go +++ b/mockgen/mockgen_test.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" ) func TestMakeArgString(t *testing.T) { diff --git a/mockgen/model/model.go b/mockgen/model/model.go index 94d7f4ba..70c52feb 100644 --- a/mockgen/model/model.go +++ b/mockgen/model/model.go @@ -24,7 +24,7 @@ import ( ) // pkgPath is the importable path for package model -const pkgPath = "github.com/golang/mock/mockgen/model" +const pkgPath = "go.uber.org/mock/mockgen/model" // Package is a Go package. It may be a subset. type Package struct { @@ -160,7 +160,7 @@ func init() { // For a non-pointer type, gob.Register will try to get package full path by // calling rt.PkgPath() for a name to register. If your project has vendor // directory, it is possible that PkgPath will get a path like this: - // ../../../vendor/github.com/golang/mock/mockgen/model + // ../../../vendor/go.uber.org/mock/mockgen/model gob.RegisterName(pkgPath+".PredeclaredType", PredeclaredType("")) } diff --git a/mockgen/parse.go b/mockgen/parse.go index 21c0d70a..aab90660 100644 --- a/mockgen/parse.go +++ b/mockgen/parse.go @@ -33,7 +33,7 @@ import ( "strconv" "strings" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" ) var ( diff --git a/mockgen/parse_test.go b/mockgen/parse_test.go index 82c831f3..3c4ba4cf 100644 --- a/mockgen/parse_test.go +++ b/mockgen/parse_test.go @@ -50,7 +50,7 @@ func TestFileParser_ParsePackage(t *testing.T) { importedInterfaces: newInterfaceCache(), } - newP, err := p.parsePackage("github.com/golang/mock/mockgen/internal/tests/custom_package_name/greeter") + newP, err := p.parsePackage("go.uber.org/mock/mockgen/internal/tests/custom_package_name/greeter") if err != nil { t.Fatalf("Unexpected error: %v", err) } @@ -84,7 +84,7 @@ func checkGreeterImports(t *testing.T, imports map[string]importedPackage) { if validatorPackage, ok := imports["validator"]; !ok { t.Errorf("Expected imports to have key \"fmt\"") } else { - expectedValidatorPackage := "github.com/golang/mock/mockgen/internal/tests/custom_package_name/validator" + expectedValidatorPackage := "go.uber.org/mock/mockgen/internal/tests/custom_package_name/validator" if validatorPackage.Path() != expectedValidatorPackage { t.Errorf("Expected validator key to have value %s but got %s", expectedValidatorPackage, validatorPackage.Path()) } @@ -94,7 +94,7 @@ func checkGreeterImports(t *testing.T, imports map[string]importedPackage) { if clientPackage, ok := imports["client"]; !ok { t.Errorf("Expected imports to have key \"client\"") } else { - expectedClientPackage := "github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1" + expectedClientPackage := "go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1" if clientPackage.Path() != expectedClientPackage { t.Errorf("Expected client key to have value %s but got %s", expectedClientPackage, clientPackage.Path()) } diff --git a/mockgen/reflect.go b/mockgen/reflect.go index 4f86a151..bcb1319d 100644 --- a/mockgen/reflect.go +++ b/mockgen/reflect.go @@ -32,7 +32,7 @@ import ( "strings" "text/template" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" ) var ( @@ -169,8 +169,8 @@ func runInDir(program []byte, dir string) (*model.Package, error) { if err := cmd.Run(); err != nil { sErr := buf.String() if strings.Contains(sErr, `cannot find package "."`) && - strings.Contains(sErr, "github.com/golang/mock/mockgen/model") { - fmt.Fprint(os.Stderr, "Please reference the steps in the README to fix this error:\n\thttps://github.com/golang/mock#reflect-vendoring-error.\n") + strings.Contains(sErr, "go.uber.org/mock/mockgen/model") { + fmt.Fprint(os.Stderr, "Please reference the steps in the README to fix this error:\n\thttps://go.uber.org/mock#reflect-vendoring-error.\n") return nil, err } return nil, err @@ -198,7 +198,7 @@ import ( "path" "reflect" - "github.com/golang/mock/mockgen/model" + "go.uber.org/mock/mockgen/model" pkg_ {{printf "%q" .ImportPath}} ) diff --git a/sample/concurrent/concurrent.go b/sample/concurrent/concurrent.go index 1fb943a4..d1ebda90 100644 --- a/sample/concurrent/concurrent.go +++ b/sample/concurrent/concurrent.go @@ -1,7 +1,7 @@ // Package concurrent demonstrates how to use gomock with goroutines. package concurrent -//go:generate mockgen -destination mock/concurrent_mock.go github.com/golang/mock/sample/concurrent Math +//go:generate mockgen -destination mock/concurrent_mock.go go.uber.org/mock/sample/concurrent Math type Math interface { Sum(a, b int) int diff --git a/sample/concurrent/concurrent_test.go b/sample/concurrent/concurrent_test.go index 878ac427..4c4ae279 100644 --- a/sample/concurrent/concurrent_test.go +++ b/sample/concurrent/concurrent_test.go @@ -5,9 +5,9 @@ import ( "context" - "github.com/golang/mock/gomock" + "go.uber.org/mock/gomock" - mock "github.com/golang/mock/sample/concurrent/mock" + mock "go.uber.org/mock/sample/concurrent/mock" ) func call(ctx context.Context, m Math) (int, error) { diff --git a/sample/concurrent/mock/concurrent_mock.go b/sample/concurrent/mock/concurrent_mock.go index 301a5bf3..055fde70 100644 --- a/sample/concurrent/mock/concurrent_mock.go +++ b/sample/concurrent/mock/concurrent_mock.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/sample/concurrent (interfaces: Math) +// Source: go.uber.org/mock/sample/concurrent (interfaces: Math) // Package mock_concurrent is a generated GoMock package. package mock_concurrent @@ -7,7 +7,7 @@ package mock_concurrent import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockMath is a mock of Math interface. diff --git a/sample/mock_user_test.go b/sample/mock_user_test.go index 1e630d2e..632928b6 100644 --- a/sample/mock_user_test.go +++ b/sample/mock_user_test.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/golang/mock/sample (interfaces: Index,Embed,Embedded) +// Source: go.uber.org/mock/sample (interfaces: Index,Embed,Embedded) // Package user_test is a generated GoMock package. package user_test @@ -14,11 +14,11 @@ import ( reflect "reflect" template0 "text/template" - gomock "github.com/golang/mock/gomock" - imp1 "github.com/golang/mock/sample/imp1" - imp2 "github.com/golang/mock/sample/imp2" - imp3 "github.com/golang/mock/sample/imp3" - imp_four "github.com/golang/mock/sample/imp4" + gomock "go.uber.org/mock/gomock" + imp1 "go.uber.org/mock/sample/imp1" + imp2 "go.uber.org/mock/sample/imp2" + imp3 "go.uber.org/mock/sample/imp3" + imp_four "go.uber.org/mock/sample/imp4" ) // MockIndex is a mock of Index interface. diff --git a/sample/user.go b/sample/user.go index adb041e1..173a01f7 100644 --- a/sample/user.go +++ b/sample/user.go @@ -1,7 +1,7 @@ // Package user is an example package with an interface. package user -//go:generate mockgen -destination mock_user_test.go -package user_test github.com/golang/mock/sample Index,Embed,Embedded +//go:generate mockgen -destination mock_user_test.go -package user_test go.uber.org/mock/sample Index,Embed,Embedded // Random bunch of imports to test mockgen. import ( @@ -18,15 +18,15 @@ import ( t2 "text/template" - "github.com/golang/mock/sample/imp1" + "go.uber.org/mock/sample/imp1" // Dependencies outside the standard library. - renamed2 "github.com/golang/mock/sample/imp2" + renamed2 "go.uber.org/mock/sample/imp2" - . "github.com/golang/mock/sample/imp3" + . "go.uber.org/mock/sample/imp3" - imp_four "github.com/golang/mock/sample/imp4" + imp_four "go.uber.org/mock/sample/imp4" ) // calls itself "imp_four" diff --git a/sample/user_test.go b/sample/user_test.go index 35cfa0f1..4c7d93c8 100644 --- a/sample/user_test.go +++ b/sample/user_test.go @@ -4,9 +4,9 @@ package user_test import ( "testing" - "github.com/golang/mock/gomock" - user "github.com/golang/mock/sample" - "github.com/golang/mock/sample/imp1" + "go.uber.org/mock/gomock" + user "go.uber.org/mock/sample" + "go.uber.org/mock/sample/imp1" ) func TestRemember(t *testing.T) {