Skip to content

Commit 14ae153

Browse files
committed
Add test cases for the multi imports on multitypes
This follows up #21 Signed-off-by: moznion <moznion@mail.moznion.net>
1 parent 4338877 commit 14ae153

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

internal/test/multitypes/structure_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,13 @@ func TestStructureBuilder(t *testing.T) {
5656
assert.EqualValues(t, givenBuzString, gotBravo.buz)
5757
assert.EqualValues(t, givenQuxInt, gotBravo.qux)
5858
}
59+
60+
func TestStructureWhichNeedsImport1Instantiation(t *testing.T) {
61+
s := NewStructureWhichNeedsImport1(nil)
62+
assert.IsType(t, &StructureWhichNeedsImport1{}, s)
63+
}
64+
65+
func TestStructureWhichNeedsImport2Instantiation(t *testing.T) {
66+
s := NewStructureWhichNeedsImport2(nil)
67+
assert.IsType(t, &StructureWhichNeedsImport2{}, s)
68+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package multitypes
2+
3+
import (
4+
"io"
5+
"net"
6+
)
7+
8+
// NOTE:
9+
// This structure file is for checking whether the compilation passes for the generated file according to this.
10+
// ref: https://github.com/moznion/gonstructor/pull/21
11+
//
12+
// Until the above pull request, the generated code hadn't passed the compilation.
13+
14+
//go:generate sh -c "$(cd ./\"$(git rev-parse --show-cdup)\" || exit; pwd)/dist/gonstructor_test --type=StructureWhichNeedsImport1 --type=StructureWhichNeedsImport2 --output structure_with_multiple_imports_gen.go --constructorTypes=allArgs,builder --withGetter"
15+
16+
type StructureWhichNeedsImport1 struct {
17+
foo net.Conn
18+
}
19+
20+
type StructureWhichNeedsImport2 struct {
21+
bar io.Reader
22+
}

0 commit comments

Comments
 (0)