Skip to content

Commit

Permalink
chore: add comments to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Nov 9, 2022
1 parent fead327 commit e07d6c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions examples/_template/example.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"github.com/testcontainers/testcontainers-go"
)

// {{ $lower }}Container represents the {{ .Name }} container type used in the module
type {{ $lower }}Container struct {
testcontainers.Container
}

// setup{{ $title }} creates an instance of the {{ .Name }} container type
func setup{{ $title }}(ctx context.Context) (*{{ $lower }}Container, error) {
req := testcontainers.ContainerRequest{
Image: "{{ .Image }}",
Expand Down
10 changes: 6 additions & 4 deletions examples/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ func assertExampleContent(t *testing.T, exampleName string, exampleImage string,

data := strings.Split(string(content), "\n")
assert.Equal(t, data[0], "package "+lower)
assert.Equal(t, data[8], "type "+lower+"Container struct {")
assert.Equal(t, data[12], "func setup"+title+"(ctx context.Context) (*"+lower+"Container, error) {")
assert.Equal(t, data[14], "\t\tImage: \""+exampleImage+"\",")
assert.Equal(t, data[24], "\treturn &"+lower+"Container{Container: container}, nil")
assert.Equal(t, data[8], "// "+lower+"Container represents the "+exampleName+" container type used in the module")
assert.Equal(t, data[9], "type "+lower+"Container struct {")
assert.Equal(t, data[13], "// setup"+title+" creates an instance of the "+exampleName+" container type")
assert.Equal(t, data[14], "func setup"+title+"(ctx context.Context) (*"+lower+"Container, error) {")
assert.Equal(t, data[16], "\t\tImage: \""+exampleImage+"\",")
assert.Equal(t, data[26], "\treturn &"+lower+"Container{Container: container}, nil")
}

// assert content go.mod
Expand Down

0 comments on commit e07d6c6

Please sign in to comment.