-
-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: generate Go examples for new modules (#1600)
* chore: rename templates to module * chore: support generating Go Examples * fix: test
- Loading branch information
1 parent
eed759d
commit 239c1c4
Showing
8 changed files
with
75 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{ $entrypoint := Entrypoint }}{{ $lower := ToLower }}{{ $title := Title }}package {{ $lower }}_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/testcontainers/testcontainers-go/modules/{{ $lower }}" | ||
) | ||
|
||
func Example{{ $entrypoint }}() { | ||
// run{{ $title }}Container { | ||
ctx := context.Background() | ||
|
||
{{ $lower }}Container, err := {{ $lower }}.{{ $entrypoint }}(ctx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Clean up the container after the test is complete | ||
defer func() { | ||
if err := {{ $lower }}Container.Terminate(ctx); err != nil { | ||
panic(err) | ||
} | ||
}() | ||
// } | ||
|
||
state, err := {{ $lower }}Container.State(ctx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println(state.Running) | ||
|
||
// Output: | ||
// true | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters