aerospike

package module
v0.1.0 Latest Latest
Warning

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

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

README

testcontainers-aerospike-go

Go Reference Go Report Card

Go library for Aerospike integration testing via Testcontainers.

Install

Use go get to install the latest version of the library.

go get -u github.com/ajeetdsouza/testcontainers-aerospike-go@latest

Usage

import (
    "context"
    "testing"

    "github.com/stretchr/testify/require"
    aero "github.com/aerospike/aerospike-client-go/v6"
    aeroTest "github.com/ajeetdsouza/testcontainers-aerospike-go"
)

func TestAerospike(t *testing.T) {
    aeroClient := setupAerospike(t)
    // your code here
}

func setupAerospike(t *testing.T) *aero.Client {
    ctx := context.Background()

    container, err := aeroTest.RunContainer(ctx)
    require.NoError(t, err)
    t.Cleanup(func() {
        err := container.Terminate(ctx)
        require.NoError(t, err)
    })

    host, err := container.Host(ctx)
    require.NoError(t, err)
    port, err := container.ServicePort(ctx)
    require.NoError(t, err)

    client, err := aero.NewClient(host, port)
    require.NoError(t, err)

    return client
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithImage

WithImage sets the image for the Aerospike container.

func WithNamespace

func WithNamespace(namespace string) testcontainers.CustomizeRequestOption

WithNamespace sets the default namespace that is created when Aerospike starts. By default, this is set to "test".

Types

type AerospikeContainer

type AerospikeContainer struct {
	testcontainers.Container
}

func RunContainer

RunContainer creates an instance of the Aerospike container type.

func (AerospikeContainer) ServicePort

func (c AerospikeContainer) ServicePort(ctx context.Context) (int, error)

Port returns the port on which the Aerospike container is listening.

Jump to

Keyboard shortcuts

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