testutils

package
v3.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TestHashKey    = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
	TestEncryptKey = "fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210"
)

Test-only encryption keys. These are hex-encoded 32-byte (64 hex chars) values. WARNING: These keys are for testing only and MUST NOT be used in production.

Variables

This section is empty.

Functions

func ApplyResourceLimits

func ApplyResourceLimits(hostConfig *container.HostConfig, memoryMB int64, cpuLimit float64)

ApplyResourceLimits configures memory and CPU limits on a container's HostConfig. This is the recommended approach for testcontainers-go (HostConfigModifier).

Parameters:

  • hostConfig: The container host configuration to modify
  • memoryMB: Memory limit in megabytes (0 = no limit)
  • cpuLimit: CPU limit in cores, e.g., 0.5 = half a core (0 = no limit)

Usage with testcontainers-go:

req := testcontainers.ContainerRequest{
    HostConfigModifier: func(hc *container.HostConfig) {
        testutils.ApplyResourceLimits(hc, 512, 1.0)
    },
}

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to the given value. This is useful for creating pointers to literals in test cases.

Example:

alias := &mmodel.Alias{
    Document: testutils.Ptr("12345678901"),
    Type:     testutils.Ptr("NATURAL_PERSON"),
}

func SetupCrypto

func SetupCrypto(t *testing.T) *libCrypto.Crypto

SetupCrypto creates a Crypto instance configured for testing. It uses fixed test keys for deterministic encryption/hashing in tests.

Example:

func TestEncryption(t *testing.T) {
    crypto := testutils.SetupCrypto(t)
    encrypted, err := crypto.Encrypt(testutils.Ptr("sensitive-data"))
    require.NoError(t, err)
}

Types

This section is empty.

Directories

Path Synopsis
Package stubs provides test doubles for tests.
Package stubs provides test doubles for tests.

Jump to

Keyboard shortcuts

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