Documentation
¶
Overview ¶
Package couchdb provides a Testcontainers module for Apache CouchDB.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithAdminCredentials ¶
func WithAdminCredentials(user, password string) testcontainers.CustomizeRequestOption
WithAdminCredentials sets the admin username and password for the CouchDB container via the COUCHDB_USER and COUCHDB_PASSWORD environment variables.
Types ¶
type Container ¶
type Container struct {
testcontainers.Container
// contains filtered or unexported fields
}
Container represents the CouchDB container type used in the module.
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
Run creates an instance of the CouchDB container type.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/couchdb"
)
func main() {
// runCouchDBContainer {
ctx := context.Background()
couchdbContainer, err := couchdb.Run(ctx, "couchdb:3",
couchdb.WithAdminCredentials("admin", "password"),
)
defer func() {
if err := testcontainers.TerminateContainer(couchdbContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
connStr, err := couchdbContainer.ConnectionString(ctx)
if err != nil {
log.Printf("failed to get connection string: %s", err)
return
}
fmt.Println(connStr[:len("http://admin:password@")])
}
Output: http://admin:password@
func (*Container) ConnectionString ¶
ConnectionString returns the HTTP connection string for the CouchDB container in the form http://user:password@host:5984. IPv6 hosts are bracketed correctly via net.JoinHostPort, and credentials containing special characters are percent-encoded via url.UserPassword.
Click to show internal directories.
Click to hide internal directories.