diff --git a/package/moq/moq.go b/package/moq/moq.go index 6ce174d..628e25e 100644 --- a/package/moq/moq.go +++ b/package/moq/moq.go @@ -8,10 +8,10 @@ import ( "go/parser" "go/token" "go/types" - "html/template" "io" "os" "strings" + "text/template" ) // Mocker can generate mock structs. diff --git a/package/moq/moq_test.go b/package/moq/moq_test.go index cd7ae02..0372756 100644 --- a/package/moq/moq_test.go +++ b/package/moq/moq_test.go @@ -114,3 +114,24 @@ func TestNothingToReturn(t *testing.T) { } } } + +func TestChannelNames(t *testing.T) { + m, err := New("testdata/channels", "") + if err != nil { + t.Errorf("moq.New: %s", err) + } + var buf bytes.Buffer + err = m.Mock(&buf, "Queuer") + if err != nil { + t.Errorf("m.Mock: %s", err) + } + s := buf.String() + var strs = []string{ + "func (mock *QueuerMock) Sub(topic string) (<-chan Queue, error)", + } + for _, str := range strs { + if !strings.Contains(s, str) { + t.Errorf("expected by missing: \"%s\"", str) + } + } +} diff --git a/package/moq/testdata/channels/example.go b/package/moq/testdata/channels/example.go new file mode 100644 index 0000000..5dfd0d0 --- /dev/null +++ b/package/moq/testdata/channels/example.go @@ -0,0 +1,7 @@ +package channels + +type Queue []string + +type Queuer interface { + Sub(topic string) (<-chan Queue, error) +}