couchdb

package module
v0.44.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 8 Imported by: 0

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

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

func (c *Container) ConnectionString(ctx context.Context) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL