agriroutertestcontainer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package agriroutertestcontainer is a testcontainers module for the agrirouter service.

Index

Constants

View Source
const (
	// PutEndpointTestEvent happens when an endpoint is put in the test container.
	PutEndpointTestEvent = "putEndpoint"

	// DeleteEndpointTestEvent happens when an endpoint is deleted in the test container.
	DeleteEndpointTestEvent = "deleteEndpoint"

	// SendMessagesTestEvent happens when messages are sent in the test container.
	SendMessagesTestEvent = "sendMessages"

	// ConfirmMessagesTestEvent happens when messages are confirmed in the test container.
	ConfirmMessagesTestEvent = "confirmMessages"

	// ReadyTestEvent indicates that the test events stream is ready.
	ReadyTestEvent = "ready"
)

Variables

View Source
var ErrExpectationFailed = fmt.Errorf("expectation failed")

ErrExpectationFailed is an error that indicates that an expected event was not received.

Functions

func OkHTTPCode

func OkHTTPCode(goodCode int) func(int) bool

OkHTTPCode returns a function that checks if the status code is equal to the provided goodCode.

Types

type AgrirouterContainer

type AgrirouterContainer struct {
	testcontainers.Container
	BaseURL string
	Events  *TestEvents
}

AgrirouterContainer represents a test container for the agrirouter service.

func Run

Run starts the agrirouter test container and returns an AgrirouterContainer instance.

func (*AgrirouterContainer) TerminateOrLog

func (c *AgrirouterContainer) TerminateOrLog()

TerminateOrLog terminates the agrirouter container and logs any errors that occur during termination.

type TestEvent

type TestEvent struct {
	Data      string
	EventType string
}

TestEvent represents a single event happened in test container.

type TestEvents

type TestEvents struct {
	// contains filtered or unexported fields
}

TestEvents helps to test whether certain events have happened during tests.

func (*TestEvents) CheckExpectations

func (e *TestEvents) CheckExpectations(t assert.TestingT) error

CheckExpectations checks if all expected events were received and resets the expectations.

func (*TestEvents) Expect

func (e *TestEvents) Expect(
	evType string,
	data string,
)

Expect adds an expectation for an event of type evType with the given data.

func (*TestEvents) IsReady added in v0.3.0

func (e *TestEvents) IsReady() bool

IsReady returns true if the ready event has been received.

type TestedEndpointPutData

type TestedEndpointPutData struct {
	ExternalID string `json:"externalId"`
}

TestedEndpointPutData represents the data structure for an event that is expected when an endpoint is put in the agrirouter test container.

Jump to

Keyboard shortcuts

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