Skip to content

Commit df8c549

Browse files
authored
fix: add import to module generation (#2537)
1 parent 2bd1ee6 commit df8c549

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

modulegen/_template/module.go.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import (
44
"context"
5+
"fmt"
56

67
"github.com/testcontainers/testcontainers-go"
78
)

modulegen/main_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,14 @@ func assertModuleContent(t *testing.T, module context.TestcontainersModule, exam
423423

424424
data := sanitiseContent(content)
425425
assert.Equal(t, data[0], "package "+lower)
426-
assert.Equal(t, data[8], "// "+containerName+" represents the "+exampleName+" container type used in the module")
427-
assert.Equal(t, data[9], "type "+containerName+" struct {")
428-
assert.Equal(t, data[13], "// "+entrypoint+" creates an instance of the "+exampleName+" container type")
429-
assert.Equal(t, data[14], "func "+entrypoint+"(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*"+containerName+", error) {")
430-
assert.Equal(t, data[16], "\t\tImage: \""+module.Image+"\",")
431-
assert.Equal(t, data[25], "\t\tif err := opt.Customize(&genericContainerReq); err != nil {")
432-
assert.Equal(t, data[26], "\t\t\treturn nil, fmt.Errorf(\"customize: %w\", err)")
433-
assert.Equal(t, data[35], "\treturn &"+containerName+"{Container: container}, nil")
426+
assert.Equal(t, data[9], "// "+containerName+" represents the "+exampleName+" container type used in the module")
427+
assert.Equal(t, data[10], "type "+containerName+" struct {")
428+
assert.Equal(t, data[14], "// "+entrypoint+" creates an instance of the "+exampleName+" container type")
429+
assert.Equal(t, data[15], "func "+entrypoint+"(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*"+containerName+", error) {")
430+
assert.Equal(t, data[17], "\t\tImage: \""+module.Image+"\",")
431+
assert.Equal(t, data[26], "\t\tif err := opt.Customize(&genericContainerReq); err != nil {")
432+
assert.Equal(t, data[27], "\t\t\treturn nil, fmt.Errorf(\"customize: %w\", err)")
433+
assert.Equal(t, data[36], "\treturn &"+containerName+"{Container: container}, nil")
434434
}
435435

436436
// assert content GitHub workflow for the module

0 commit comments

Comments
 (0)