Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit bb827da

Browse files
committed
Add test of mockgen for embed option
1 parent f11c7db commit bb827da

File tree

5 files changed

+177
-0
lines changed

5 files changed

+177
-0
lines changed

mockgen/internal/tests/embed/input.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package embed
2+
3+
//go:generate mockgen -embed -package embed -destination mock.go . Hoge
4+
//go:generate mockgen -embed -destination mock/mock.go . Hoge
5+
6+
type Hoge interface {
7+
Fuga() error
8+
mustImplementedFunction()
9+
}
10+
11+
type HogeImpl struct {
12+
s string
13+
}
14+
15+
func (h *HogeImpl) Fuga() error {
16+
return nil
17+
}

mockgen/internal/tests/embed/mock.go

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mockgen/internal/tests/embed/mock/mock.go

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package mock_embed_test
2+
3+
import (
4+
reflect "reflect"
5+
"testing"
6+
7+
"github.com/golang/mock/gomock"
8+
"github.com/golang/mock/mockgen/internal/tests/embed"
9+
mock_embed "github.com/golang/mock/mockgen/internal/tests/embed/mock"
10+
)
11+
12+
func TestEmbed(t *testing.T) {
13+
hoge := mock_embed.NewMockHoge(gomock.NewController(t))
14+
et := reflect.TypeOf((*embed.Hoge)(nil)).Elem()
15+
ht := reflect.TypeOf(hoge)
16+
if !ht.Implements(et) {
17+
t.Errorf("source interface has been not implemented")
18+
}
19+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package embed_test
2+
3+
import (
4+
reflect "reflect"
5+
"testing"
6+
7+
"github.com/golang/mock/gomock"
8+
"github.com/golang/mock/mockgen/internal/tests/embed"
9+
)
10+
11+
func TestEmbed(t *testing.T) {
12+
hoge := embed.NewMockHoge(gomock.NewController(t))
13+
et := reflect.TypeOf((*embed.Hoge)(nil)).Elem()
14+
ht := reflect.TypeOf(hoge)
15+
if !ht.Implements(et) {
16+
t.Errorf("source interface has been not implemented")
17+
}
18+
}

0 commit comments

Comments
 (0)