-
Notifications
You must be signed in to change notification settings - Fork 346
Open
Description
I may find a bug for this code: some import paths may be lost when receiver and its methods are defined in different file.
Describe the bug
Some import paths may be lost when receiver and its methods are defined in different file.
How To Reproduce
File tree of my golang project:
|____field
| |____field.go
|____method.go
|____receiver.go
|____go.mod
receiver.go
package test
import "AtwoodHuang/test/field"
type Foo struct {
Bar string
TestFiled field.Test
}
method.go
package test
func (*Foo) Foo(s string) error {
return nil
}
field/field.go
package field
type Test struct {
}
Bugs
when generate test function for method Foo(s string) error
, gotests miss import path for TestFiled
in receiver Foo
.(missing import path is AtwoodHuang/test/field
)
package test
import "testing"
func TestFoo_Foo(t *testing.T) {
type fields struct {
Bar string
TestFiled field.Test
}
type args struct {
s string
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := &Foo{
Bar: tt.fields.Bar,
TestFiled: tt.fields.TestFiled,
}
if err := f.Foo(tt.args.s); (err != nil) != tt.wantErr {
t.Errorf("Foo.Foo() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
How To Fix
I will push a PR to fix this bug latter.
Metadata
Metadata
Assignees
Labels
No labels