Skip to content

Commit

Permalink
Add test for package import of type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-suhas committed Aug 24, 2021
1 parent ab5b7bc commit 9311dad
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// Version is the command version, injected at build time.
var Version string = "dev"
var Version = "dev"

type userFlags struct {
outFile string
Expand Down
8 changes: 8 additions & 0 deletions pkg/moq/moq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ func TestMockGolden(t *testing.T) {
interfaces: []string{"Example"},
goldenFile: filepath.Join("testpackages/anonimport", "iface_moq.golden.go"),
},
{
// Tests import of package for aliased type.
// See https://github.com/matryer/moq/issues/153.
name: "TypeAliasPkgImport",
cfg: Config{SrcDir: "testpackages/typealiaspkgimport"},
interfaces: []string{"Processor"},
goldenFile: filepath.Join("testpackages/typealiaspkgimport", "processor_moq.golden.go"),
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions pkg/moq/testpackages/typealiaspkgimport/alias/message.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package alias

import "github.com/matryer/moq/pkg/moq/testpackages/typealiaspkgimport/internal/message"

type Message = message.Message
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package message

type Message struct{}
7 changes: 7 additions & 0 deletions pkg/moq/testpackages/typealiaspkgimport/processor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package typealiaspkgimport

import "github.com/matryer/moq/pkg/moq/testpackages/typealiaspkgimport/alias"

type Processor interface {
Process(msg alias.Message) error
}
74 changes: 74 additions & 0 deletions pkg/moq/testpackages/typealiaspkgimport/processor_moq.golden.go

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

0 comments on commit 9311dad

Please sign in to comment.