Commit Graph

54 Commits

Author SHA1 Message Date
Suhas Karanth
8f50fb6793
Avoid deprecated LoadModes packages.{LoadFiles, LoadSyntax} (#116)
From the docs for packages.{LoadFiles, LoadSyntax} -
https://godoc.org/golang.org/x/tools/go/packages#pkg-constants

	// Deprecated: LoadFiles exists for historical compatibility
	// and should not be used. Please directly specify the needed
	// fields using the Need values.
	// ...
	// Deprecated: LoadSyntax exists for historical compatibility
	// and should not be used. Please directly specify the needed
	// fields using the Need values.
2020-01-17 10:25:50 +05:30
Suhas Karanth
75d0ddfc00
Run go generate (#119)
Minor changes to generated test file because of #110.
2020-01-06 18:41:00 +05:30
Suhas Karanth
0e0395200a
Improve comment on type guard in template (#113)
If the user specifies a different package and the mock name is the same
as the interface name, the type guard comment will be of the following
format:

	// Ensure, that MyInterface does implement MyInterface.

So use the $sourcePackagePrefix in the comment.
2019-11-06 08:58:47 +05:30
Suhas Karanth
1206bf1e2a
Allow aliasing interface name (#110)
Implementation based on #57.
2019-11-05 13:13:49 +05:30
Pedram Hajesmaeeli
5e2b3bdd91 Fix moq for go 1.13 and avoid creating empty directory (#105)
* Fix moq for go 1.13 and avoid creating empty directory

This fixes #103 and also fixes #102

* Update .travis.yml
2019-11-03 07:46:59 +00:00
Ivan Safonov
2fdf5e1752 fix cyclic dependency with go modules 2019-03-01 00:22:20 +07:00
Ivan Safonov
e17abc4d5d fix cyclic dependency with go modules 2019-02-28 23:49:51 +07:00
Mat Ryer
c26fdca584
Merge branch 'master' into master 2019-02-11 10:48:04 +00:00
Ivan Safonov
6c76dadc23 Support go modules by using go/packages instead of go/loader 2019-01-23 21:36:46 +07:00
Lucas Bremgartner
81c463c9b9 Add import, if source pkg is not destination pkg
Fixes #86
2019-01-22 21:40:29 +01:00
Ivan Safonov
1174b6968d Support go modules by using go/packages instead of go/loader 2019-01-23 00:52:12 +07:00
Mat Ryer
effe366417
Merge branch 'master' into TestVendoredBuildConstraints 2019-01-21 17:39:53 +00:00
Mat Ryer
5b2282d8e5
Merge branch 'master' into static-interface-check 2019-01-21 17:22:41 +00:00
Mat Ryer
2647bdb8ea
Merge branch 'master' into TestVendoredBuildConstraints 2019-01-21 17:17:03 +00:00
Mat Ryer
7855d5d508
Merge branch 'master' into static-interface-check 2019-01-21 17:15:50 +00:00
Mat Ryer
84ab8b08ea
Merge branch 'master' into abs-path-modules 2019-01-21 17:12:59 +00:00
Lucas Bremgartner
b21592468b Add static interface implementation check
Add an additional line of code per interface to the generated mock file,
which allows the go compiler to statically check if the mock implements
the mocked interface.
2019-01-17 20:20:37 +01:00
Lucas Bremgartner
2eb3df732a Update mocks with go generate 2019-01-17 20:19:34 +01:00
Lucas Bremgartner
d95e87fb17 Import package by files if outside of GOPATH
This is for example the case, if a mock is generated for an external
interface while go modules are enabled.

Fixes: #79
2019-01-17 20:18:30 +01:00
Harald Nordgren
964359ea22 Create 'TestVendoredBuildConstraints' 2018-09-18 15:44:55 +02:00
pdrum
764e1ef8e5 Remove TODO comments from template.go 2018-08-09 01:41:52 +04:30
Frederik Vosberg
c3b38fdc87 [FIX] import path of test package 2018-07-11 08:29:15 +02:00
Frederik Vosberg
80d25dbad5 [FIX] import package with same name misses package qualifier 2018-07-11 08:23:28 +02:00
Frederik Vosberg
b60f573125 [FIX] tests assertion 2018-07-10 16:47:25 +02:00
Frederik Vosberg
fc06e5c36a [TEST] check missing package name for packages with the same name 2018-07-10 16:22:49 +02:00
Lucas Bremgartner
f70153ef95 Update files generated by moq 2018-06-12 13:40:29 +02:00
Mat Ryer
0ab5038f6e
Merge branch 'master' into patch-2 2018-06-12 09:33:48 +01:00
Lucas Bremgartner
6af989dedc Implement "DO NOT EDIT" comment convention
Update all generated files with `go generate ./...`.

See golang/go#13560 for details.
2018-04-18 09:38:43 +02:00
Mat Ryer
1861224bf0
Merge branch 'master' into patch-2 2018-03-07 09:08:08 +00:00
Uwe Dauernheim
12b80de6ea Remove moq prefix 2018-02-10 17:56:34 +01:00
Stefan Warman
565e1649f5 Use x/tools/go/loader to load packages instead of custom importer. 2018-02-05 14:29:41 +01:00
Mat Ryer
acbb9b7883
Merge branch 'master' into appease-golint 2017-12-06 15:07:50 +00:00
Mat Ryer
595a9745ee added go generate with vendor test 2017-12-06 15:01:42 +00:00
Don Petersen
b2769851ce Ensure generated content is friendlier to golint
I've stolen the list of "initialisms" from the golint codebase. Normally
I might try and figure out some way to bring the list in from the source
rather than just copy and paste it, since it may fall out of date in the
future. However, if you've ever followed any of the PRs in the golint
repository, you'll know any change like that would likely be rejected.
Most of this list hasn't changed in the last 4 years, so my feeling is
that it won't require many more updates for the life of this project.
2017-11-13 00:33:12 +00:00
Frederik Vosberg
a2671b9bfc Added missing test package for empty interface mocking 2017-08-02 22:57:43 +02:00
Frederik Vosberg
d17151fc4e Merge branch 'master' into fix-emptyinterfaces 2017-08-02 22:26:59 +02:00
Mat Ryer
71d368f14f golint fixes 2017-08-02 16:06:35 +01:00
Mat Ryer
bd3bf33613 golint fixes 2017-08-02 16:05:42 +01:00
Frederik Vosberg
e2c68b96ea Merge branch 'master' into fix-test-execution-in-forks 2017-08-02 10:13:34 +02:00
Mat Ryer
fc157a141f added go fmt 2017-07-31 15:09:54 +01:00
Mat Ryer
463b834355 Merge branch 'master' into fix-test-execution-in-forks 2017-07-31 14:59:37 +01:00
Frederik Vosberg
ede55fbbe7 [PATCH] Omit sync package while mocking empty interface
when just an empty interface is has beeing mocked, the import of the sync package caused an error. In production it isn't important, because mocking empty interfaces might be stupid, but while writing tests it might happen, that you create an interface, which is beeing filled later on.
2017-07-27 21:08:06 +02:00
Frederik Vosberg
10bc283502 [PATCH] Made tests independent from package path
The test case checked for a whole package path, which should exist in a generated moq file, but that failed for obvious reasons in forks
2017-07-27 21:05:01 +02:00
Frederik Vosberg
c4b6b29db7 [PATCH] Remove side effect caused by chdir from test - fixes #23
The TestDotImports changed the directory, so every test afterwards was executed from another directory and calls like New("testpackages/emptyinterface", "") failed.
2017-07-27 21:02:36 +02:00
Mat Ryer
df933a7865 Cleaned up files 2017-07-18 10:06:16 +01:00
Mat Ryer
e71b1c1ebe Better solution for #21 2017-07-18 10:00:26 +01:00
Mat Ryer
879118f880 Single dot imports explicitly not-included - fixes #21 2017-07-18 09:45:29 +01:00
SteveOC
afd0cccab1 update template header to conform to https://github.com/golang/go/issues/13560 'new standard way of denoting generated code' 2017-07-18 14:00:03 +10:00
Mat Ryer
9dfde8fc79 Improved the way calls and locks work 2017-07-11 21:27:08 +01:00
Mat Ryer
b442eec838 changed the way locks work to keep them out of the mock structure itself 2017-07-11 21:00:24 +01:00