This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test of mockgen for embed option
- Loading branch information
Showing
5 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package embed | ||
|
||
//go:generate mockgen -embed -package embed -destination mock.go . Hoge | ||
//go:generate mockgen -embed -destination mock/mock.go . Hoge | ||
|
||
type Hoge interface { | ||
Fuga() error | ||
mustImplementedFunction() | ||
} | ||
|
||
type HogeImpl struct { | ||
s string | ||
} | ||
|
||
func (h *HogeImpl) Fuga() error { | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package mock_embed_test | ||
|
||
import ( | ||
reflect "reflect" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/golang/mock/mockgen/internal/tests/embed" | ||
mock_embed "github.com/golang/mock/mockgen/internal/tests/embed/mock" | ||
) | ||
|
||
func TestEmbed(t *testing.T) { | ||
hoge := mock_embed.NewMockHoge(gomock.NewController(t)) | ||
et := reflect.TypeOf((*embed.Hoge)(nil)).Elem() | ||
ht := reflect.TypeOf(hoge) | ||
if !ht.Implements(et) { | ||
t.Errorf("source interface has been not implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package embed_test | ||
|
||
import ( | ||
reflect "reflect" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/golang/mock/mockgen/internal/tests/embed" | ||
) | ||
|
||
func TestEmbed(t *testing.T) { | ||
hoge := embed.NewMockHoge(gomock.NewController(t)) | ||
et := reflect.TypeOf((*embed.Hoge)(nil)).Elem() | ||
ht := reflect.TypeOf(hoge) | ||
if !ht.Implements(et) { | ||
t.Errorf("source interface has been not implemented") | ||
} | ||
} |