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 ¶
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.
Click to show internal directories.
Click to hide internal directories.