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

Commit

Permalink
Add test of mockgen for embed option
Browse files Browse the repository at this point in the history
  • Loading branch information
stoikheia committed Nov 20, 2022
1 parent 040104e commit 5c42721
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mockgen/internal/tests/embed/input.go
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
}
61 changes: 61 additions & 0 deletions mockgen/internal/tests/embed/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions mockgen/internal/tests/embed/mock/mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions mockgen/internal/tests/embed/mock/mock_test.go
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")
}
}
18 changes: 18 additions & 0 deletions mockgen/internal/tests/embed/mock_test.go
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")
}
}

0 comments on commit 5c42721

Please sign in to comment.