Граф коммитов

71 Коммитов

Автор SHA1 Сообщение Дата
Cody Oss 953a5bb40e
update user mock to be in test package (#566)
Fixes: #560
2021-06-04 13:31:10 -06:00
Cody Oss bb5fd5e98f
fix linter errors (#552) 2021-04-23 14:45:47 -06:00
Roger f36d14a475
test(sample/user_test.go): minor correction at t.Errorf (#544) 2021-03-22 08:47:27 -06:00
Cody Oss 70785154b0
refactor go:generate lines so they are consistently placed (#527) 2021-02-23 15:16:24 -07:00
Tim Ebert 8734ec565a
Format generated files with goimports (#458) 2020-07-31 09:34:41 -07:00
Cole Wippern 91d4b5c4fd
Add tests for various Do/DoAndReturn calls (#430) 2020-07-25 20:32:24 -06:00
Denis Krivak 0b87a54da2
Add a period to the end of comments (#414) 2020-03-23 15:44:12 -06:00
Cody Oss 3dcdcb6994
fix not resolving go module major versions (#385)
This change now makes use of go list to check for package names. This
tool is module aware and allows for better named imports.

To test this change I needed to also add a small package to our mod
file. To keep this import from disappearing from go.mod I made use
of the tools file strategy.

Note this change will change the import names in generated code. This
should not be a breaking change in user code.

Fixes #326
2020-01-20 12:21:39 -07:00
Cody Oss 0b73a1dbc3
refactor to unify README styles (#338) 2019-10-23 22:23:07 -06:00
poy 51421b967a mockgen: use Controller.Helper() in generated mocks
Using T.Helper() better directs the callstack to point at the
offending line in the production code.

fixes #239
2018-12-07 20:39:06 -07:00
Alex Zemlyakov 362bc29cc0 "golang.org/x/net/context" was replaced to "context" package 2018-12-03 15:53:35 -07:00
Dmitry Savintsev 0072d85958 fix outdated reference to update_mock.sh script
update_mock.sh script was deleted in 2f85419.

Fixes #142.
2018-08-20 11:25:49 +02:00
Hesky Fisher 0bea072b12 Fix variadic argument matching 2018-04-03 23:51:01 +00:00
Hesky Fisher e4a9bdc6d0 Replace context with golang.org/x/net/context 2017-10-20 11:04:26 -04:00
Hesky Fisher 6e20fef50e Merge pull request #111 from abbot/withcontext
gomock.WithContext: controller with a context
2017-10-10 13:49:32 -04:00
hori-ryota df8ec80ed5 Merge branch 'master' into feature/fix-variadic-mock 2017-10-01 14:00:39 +09:00
Lev Shamardin b219c2d437 Disable TestConcurrentFails.
Otherwise integration tests are unhappy.
2017-09-21 00:22:06 +01:00
Lev Shamardin da057c5524 gomock.WithContext: controller with a context which is cancelled on Fatals.
testing.T.FailNow (and Fatal, ...) work only when called from the same
goroutine as the test. This makes using gomock with e.g. RPC server
mocks quite a challenge as the tests are likely to deadlock instead of
failing properly.

This adds a new constructor returning an additional context, which is
cancelled on any fatal failure in mock.
2017-09-21 00:13:24 +01:00
Matt T. Proud 980b783e0f mockgen: emit package doc comments by default.
This commit enhances the cosmetic output of the mockgen code generator
such that its output includes package-level comment documentation.  It
can be disabled by setting the `--write_package_comment` flag to
`false`.  Disabling it is only useful to prevent clobbering of existing
package documentation, which would occur if the user instructed mockgen
to emit its output to a pre-existing Go package that contains end-user
public API.

This change is motivated by several things:

(1.) enhancing the readability of http://godoc documentation for large
     package trees.

(2.) providing a differentiable characteristic from other
     human-written packages.  This helps both humans and programs
     differentiate between packages themselves for purposes of
     classification, which is useful when automatically refactorings
     across an entire codebase like a monorepo.

(3.) keeping the output stylistically consistent with that emitted from
     the protoc-gen-go code generator, which Protocol Buffers uses.
2017-08-21 17:12:08 +02:00
hori-ryota f159d62078 Fix variadic mock for gomock.Any() . fix #68 2017-08-18 17:00:37 +09:00
pasztorpisti d346133c5a Specify type once for consecutive args of the same type 2017-08-15 18:12:31 +01:00
pasztorpisti 0f2bb9ec14 Fix arg name conflicts
- Arg names no longer conflict with generated identifiers like _m, _mr, _s, etc...
- Using the original arg names when generating the mock recorder
2017-08-15 18:12:24 +01:00
Hesky Fisher dea6b4faed Restore backwards compatibility for controller.RecordCall. 2017-07-22 10:29:51 -04:00
Hesky Fisher 562b587d81 Fix #51 2017-07-21 15:56:48 -04:00
pasztorpisti 2f854191f0 add travis-ci config 2017-06-28 02:18:11 +01:00
Hesky (Yechezkia) Fisher a0f6e76e2f Update checked in mocks with new output. 2017-06-22 16:21:41 -04:00
Hesky Fisher b2105fd81b Merge pull request #61 from msabramo/fix_Do_for_variadic_funcs
Fix Do method for variadic functions
2017-06-20 21:37:04 -04:00
Marc Abramowitz 00dcfd4024 Fix Do method for variadic functions
Without this fix, using the `Do` method on a variadic function will
cause a panic, because not all of the arguments will be propagated to
the action function:

```
$ go test ./sample
--- FAIL: TestVariadicFunction (0.00s)
panic: reflect: Call using zero Value argument [recovered]
	panic: reflect: Call using zero Value argument [recovered]
	panic: reflect: Call using zero Value argument
...
github.com/golang/mock/gomock.(*Controller).Finish(0xc4200d57a0)
	/gopath/src/github.com/golang/mock/gomock/controller.go:149 +0x320
...
github.com/golang/mock/gomock.(*Call).call.func1()
	/gopath/src/github.com/golang/mock/gomock/call.go:234 +0x6a
...
FAIL	github.com/golang/mock/sample	0.013s
```
2017-02-01 19:52:43 -08:00
David Drysdale cfdb38615a Update generated mocks 2017-01-30 13:16:41 +00:00
David Symonds 06883d979f mockgen: Support struct{} in types when in source mode.
Fixes #8.
2015-08-21 13:58:37 +10:00
David Symonds 15f8b22550 Update import paths to be based on github.com/golang/mock. 2015-06-12 10:28:13 -07:00
David Symonds 6ce1aa0c50 Fix handling of nil passed to EXPECT() methods.
A nil passed to such a method would be wrapped as Eq(nil),
which would only match other nil interface values. That's
not helpful if the method takes a nilable concrete type
(e.g. a pointer). The fix here is to handle nil specially
and store it as Nil() instead.
2014-06-25 11:36:41 +10:00
David Symonds 1d31a78edb Fix handling of nil interface parameters being passed to Do funcs. 2014-02-12 15:33:58 +11:00
David Symonds 9dcd4b2cd0 Fix import name conflict resolution. 2012-08-30 09:43:23 +10:00
David Symonds 313d6a300f Hack to work around a compiler bug in the reflection data of byte. 2012-07-24 13:19:07 +10:00
David Symonds 215b545f0c Fix reflection of variadic methods. 2012-06-30 16:29:36 -07:00
David Symonds 8bfdb33836 Add -exec_only flag for only executing an already-built reflect helper program. 2012-06-30 16:25:21 -07:00
David Symonds b7743887a2 Merge branch 'master' into reflect
Conflicts:
	sample/mock_user/mock_user.go
	update_mocks.sh
2012-06-23 10:32:32 -07:00
David Symonds b1a3454a7d Move back to code.google.com. 2012-06-23 10:28:44 -07:00
David Symonds 417a50bb08 Support multiple interfaces. 2012-06-14 17:28:28 -07:00
David Symonds ea096c3c66 Restructure MockGen into separate parsing and code generation stages.
There is a new subpackage, mockgen/model, which is an abstract
representation of a Go package. The source-based parser constructs a
model.Package, and the code generator works solely from that.
This will make future approaches (e.g. reflection-based parser) easier.

In the process I have cleaned up a bunch of the crufty package-handling
code. This should be easier to work with in the future.
2012-06-03 16:35:01 +10:00
David Symonds 7c6d71c9fd Handle nil Return values. 2012-05-27 13:58:41 +10:00
David Symonds 8132ae8777 Relax to type assignability for values passed to Call.Return. 2012-05-27 12:49:58 +10:00
David Symonds f4bb4594cc Fix variadic methods whose variadic argument type is not interface{}. 2012-04-20 23:30:59 +10:00
David Symonds 9105240372 Run internal testing mocks through gofmt. 2012-04-20 14:27:24 +10:00
David Symonds e4ca772fac Fix code generation for variadic methods. 2012-04-20 14:25:31 +10:00
David Symonds 12b2ecb102 Add generated mock for sample. 2012-02-12 14:35:23 +11:00
Aaron Jacobs 4c807125a6 Fixed a broken import path, making 'go test' work with the sample.
For issue #2.
2012-01-07 20:40:40 +11:00
David Symonds ad1ce442f0 Remove a mention of os.Error. 2012-01-07 18:43:13 +11:00
David Symonds 60a2eeb9fe Fix mock generation of ellipsis-only method signatures. 2012-01-07 18:40:09 +11:00