-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement database containers #19
Comments
Yep, this looks like a great idea. Can you write down some code here to help me understand how you imagine interacting with the postgres utils? probably just a fake test is enough |
Should we start packaging this kind of solutions in a subpackage? Maybe a directory called ctx := context.Background()
mySql, err := canned.MySqlContainer(ctx, testcontainers.GenericContainerRequest{
Started: true,
})
mySql.GetClient() // returns a SQL client ready to be used Having a The MySql Container will attach the |
Reference #19 I bootstrapped a mysql canned container. ``` ctx := context.Background() c, err := MySQLContainer(ctx, MySQLContainerRequest{ RootPassword: "root", Database: "hello", }) if err != nil { t.Fatal(err.Error()) } defer c.Container.Terminate(ctx) sqlC, err := c.GetDriver("root", "root", "hello") if err != nil { t.Fatal(err.Error()) } _, err = sqlC.ExecContext(ctx, "CREATE TABLE example ( id integer, data varchar(32) )") if err != nil { t.Fatal(err.Error()) } ``` Signed-off-by: Gianluca Arbezzano <[email protected]>
Reference #19 I bootstrapped a mysql canned container. ``` ctx := context.Background() c, err := MySQLContainer(ctx, MySQLContainerRequest{ RootPassword: "root", Database: "hello", }) if err != nil { t.Fatal(err.Error()) } defer c.Container.Terminate(ctx) sqlC, err := c.GetDriver("root", "root", "hello") if err != nil { t.Fatal(err.Error()) } _, err = sqlC.ExecContext(ctx, "CREATE TABLE example ( id integer, data varchar(32) )") if err != nil { t.Fatal(err.Error()) } ``` Signed-off-by: Gianluca Arbezzano <[email protected]>
I'd be happy to write a Neo4j integration. |
While this is being implemented, you might try using Gnomock which sets up databases and other services, and includes initial state setup features. |
I am gonna this issue for now! As you can read in our documentation Golang is not really flexible when it comes to managing multiple modules in the same project and dependency management is still a pain. https://golang.testcontainers.org/modules/ We decided to stay focused on the core library for now. If you decide to develop your module open a PR and link it in our documentation. We are happy to share it with the community but not to maintain it directly at this stage ❤️ |
Hello @gianarb, I'm wondering if you'd reconsider integrating database modules today? |
We started this PR, which could be the seed for modules: #618 It creates examples to be consumed by the website, but turning them into modules would be a matter of adjusting the templates. |
The java implementation of testcontainers provides useful preconfigured setups for certain databases.
They usually predefine an image and setup the special waiting strategy for that database.
This should be straight-forward for Go as well since there are many database clients around to do this.
I think I'll get started with a
postgres
setup.The text was updated successfully, but these errors were encountered: