[TEST] check missing package name for packages with the same name
This commit is contained in:
parent
f4ed779510
commit
fc06e5c36a
@ -271,3 +271,20 @@ func TestGoGenerateVendoredPackages(t *testing.T) {
|
|||||||
t.Error("contains vendor directory in import path")
|
t.Error("contains vendor directory in import path")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImportedPackageWithSameName(t *testing.T) {
|
||||||
|
m, err := New("testpackages/samenameimport", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("moq.New: %s", err)
|
||||||
|
}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err = m.Mock(&buf, "Example")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("mock error: %s", err)
|
||||||
|
}
|
||||||
|
s := buf.String()
|
||||||
|
if !strings.Contains(s, `"samenameimport.A"`) {
|
||||||
|
t.Error("missing samenameimport.A to address the struct A from the external package samenameimport")
|
||||||
|
}
|
||||||
|
t.Logf("\n\n%s\n\n", s)
|
||||||
|
}
|
||||||
|
8
pkg/moq/testpackages/samenameimport/samename.go
Normal file
8
pkg/moq/testpackages/samenameimport/samename.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package samename
|
||||||
|
|
||||||
|
import samename "github.com/matryer/moq/pkg/moq/testpackages/samenameimport/samenameimport"
|
||||||
|
|
||||||
|
// Example is used to test issues with packages, which import another package with the same name
|
||||||
|
type Example interface {
|
||||||
|
Do(a samename.A) error
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package samename
|
||||||
|
|
||||||
|
// The A is used in the parent package as a dependency
|
||||||
|
type A struct{}
|
Loading…
Reference in New Issue
Block a user