testutil

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

Test Utilities

Container image constants for integration testing.

Overview

The testutil package provides centralized Docker container image definitions used across all integration tests. This ensures consistency and simplifies version management.

Features

  • Database Images - ClickHouse, MySQL, Postgres, MongoDB, Redis
  • Elasticsearch Images - Versions 7, 8, and 9
  • AWS Services - LocalStack for AWS service emulation
  • Monitoring - Prometheus for metrics testing
  • Centralized Management - Single source of truth for image versions

Installation

go get -u github.com/common-library/go/testutil

Quick Start

import "github.com/common-library/go/testutil"

container := testcontainers.ContainerRequest{
    Image: testutil.PostgresImage,
    ExposedPorts: []string{"5432/tcp"},
    // ...
}

Available Images

Database Images
  • ClickHouseImage - ClickHouse OLAP database
  • MySQLImage - MySQL relational database
  • PostgresImage - PostgreSQL database
  • MongoImage - MongoDB document database
  • RedisImage - Redis key-value store
Elasticsearch Images
  • ElasticsearchV7Image - Elasticsearch 7.x
  • ElasticsearchV8Image - Elasticsearch 8.x
  • ElasticsearchV9Image - Elasticsearch 9.x
Service Images
  • LocalstackImage - LocalStack for AWS services
  • PrometheusImage - Prometheus monitoring

Example

package mytest

import (
    "testing"
    "github.com/testcontainers/testcontainers-go"
    "github.com/common-library/go/testutil"
)

func TestWithPostgres(t *testing.T) {
    req := testcontainers.ContainerRequest{
        Image: testutil.PostgresImage,
        ExposedPorts: []string{"5432/tcp"},
        Env: map[string]string{
            "POSTGRES_PASSWORD": "password",
        },
    }
    
    container, _ := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
        ContainerRequest: req,
        Started: true,
    })
    defer container.Terminate(ctx)
    
    // Run tests...
}

Dependencies

None - constants only.

Further Reading

Documentation

Overview

Package testutil provides testing utilities and container image constants.

This package centralizes Docker container image versions used across all database and service integration tests. Maintaining images here ensures consistency and simplifies version updates.

Features

  • Database container images (ClickHouse, MySQL, Postgres, Mongo, Redis)
  • Elasticsearch images (v7, v8, v9)
  • AWS service images (LocalStack)
  • Monitoring images (Prometheus)
  • Centralized version management

Basic Example

import "github.com/common-library/go/testutil"

container := testcontainers.ContainerRequest{
    Image: testutil.PostgresImage,
    // ...
}

Index

Constants

View Source
const (
	// Database images
	ClickHouseImage = "clickhouse/clickhouse-server:25.12.1-alpine"
	MySQLImage      = "mysql:9.5.0"
	PostgresImage   = "postgres:18.1-alpine"
	MongoImage      = "mongo:8.2.3"
	RedisImage      = "redis:8.4.0-alpine3.22"

	// Elasticsearch images (versioned)
	ElasticsearchV7Image = "elasticsearch:7.17.28"
	ElasticsearchV8Image = "elasticsearch:8.19.9"
	ElasticsearchV9Image = "elasticsearch:9.2.3"

	// AWS service images
	LocalstackImage = "localstack/localstack:4.12.0"

	// Monitoring images
	PrometheusImage = "prom/prometheus:v3.8.1"
)

Container images used across all database tests. Centralizing image versions here makes it easy to update and maintain consistency.

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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