Documentation
¶
Overview ¶
Package agriroutertestcontainer is a testcontainers module for the agrirouter service.
Index ¶
Constants ¶
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 ¶
var ErrExpectationFailed = fmt.Errorf("expectation failed")
ErrExpectationFailed is an error that indicates that an expected event was not received.
Functions ¶
func OkHTTPCode ¶
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 ¶
func Run(ctx context.Context) (*AgrirouterContainer, error)
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 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.