testutil

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AttemptFactory = &mockAttemptFactory{}
View Source
var DestinationFactory = &mockDestinationFactory{}
View Source
var EventFactory = &mockEventFactory{}
View Source
var TenantFactory = &mockTenantFactory{}
View Source
var TestTopics = []string{
	"user.created",
	"user.deleted",
	"user.updated",
}

must be sorted

Functions

func CheckIntegrationTest

func CheckIntegrationTest(t *testing.T)

func CheckJSONResponse added in v1.6.0

func CheckJSONResponse(header http.Header, body []byte) error

CheckJSONResponse reports why a response is not JSON with a body.

func CreateTestLogger

func CreateTestLogger(t *testing.T) *logging.Logger

func CreateTestRedisClient

func CreateTestRedisClient(t *testing.T) internalredis.Client

func CreateTestRedisConfig

func CreateTestRedisConfig(t *testing.T) *internalredis.RedisConfig

func DeclareTestAWSInfrastructure

func DeclareTestAWSInfrastructure(ctx context.Context, cfg *mqs.AWSSQSConfig, attributes map[string]string) (string, error)

func DeclareTestRabbitMQInfrastructure

func DeclareTestRabbitMQInfrastructure(ctx context.Context, config *mqs.RabbitMQConfig) error

func ExtractRabbitPassword

func ExtractRabbitPassword(endpoint string) string

ExtractRabbitPassword extracts the password from the endpoint for example: amqp://u:p@localhost:5672 -> p

func ExtractRabbitURL

func ExtractRabbitURL(endpoint string) string

ExtractRabbitURL extracts the address from the endpoint for example: amqp://guest:guest@localhost:5672 -> localhost:5672

func ExtractRabbitUsername

func ExtractRabbitUsername(endpoint string) string

ExtractRabbitUsername extracts the username from the endpoint for example: amqp://u:p@localhost:5672 -> u

func Integration

func Integration(t *testing.T)

func MustMarshalJSON

func MustMarshalJSON(v any) []byte

func NewMockEventTracer

func NewMockEventTracer(exporter traceSDK.SpanExporter) *mockEventTracerImpl

func Race

func Race(t *testing.T)

func RandomPort

func RandomPort() string

RandomPort returns a random port string in the range :10000–:59999.

func RandomPortNumber

func RandomPortNumber() int

func RandomString

func RandomString(length int) string

func RequireErrorResponse added in v1.6.0

func RequireErrorResponse(t testing.TB, resp *httptest.ResponseRecorder, status int, message string)

RequireErrorResponse asserts that resp is the JSON error envelope with the given status code and message.

func RequireJSONResponse added in v1.6.0

func RequireJSONResponse(t testing.TB, request string, status int, header http.Header, body []byte)

RequireJSONResponse fails the test unless an API response has Content-Type application/json and a JSON object or array as its body. request describes the request in the failure message, e.g. "GET /api/v1/tenants".

func SkipUnlessCompat added in v0.12.0

func SkipUnlessCompat(t *testing.T)

func TeardownTestRabbitMQInfrastructure

func TeardownTestRabbitMQInfrastructure(ctx context.Context, cfg *mqs.RabbitMQConfig) error

Types

type MockMsg

type MockMsg struct {
	ID string
}

func (*MockMsg) FromMessage

func (m *MockMsg) FromMessage(msg *mqs.Message) error

func (*MockMsg) ToMessage

func (m *MockMsg) ToMessage() (*mqs.Message, error)

Jump to

Keyboard shortcuts

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