Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Package import of type alias #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.