Documentation
¶
Index ¶
Examples ¶
Constants ¶
const (
// DefaultImage is the default Microcks image used to mock the Resend API.
DefaultImage = "quay.io/microcks/microcks-uber:1.12.0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
*microcks.MicrocksContainer
// contains filtered or unexported fields
}
Container wraps a MicrocksContainer pre-loaded with the Resend OpenAPI spec.
func Run ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
Run creates an instance of the Container type, starting a Microcks container pre-loaded with the Resend OpenAPI spec.
Example ¶
// runContainer {
ctx := context.Background()
ctr, err := resend.Run(ctx, resend.DefaultImage)
defer func() {
if err := testcontainers.TerminateContainer(ctr); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := ctr.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(state.Running)
Output: true
func (*Container) BaseURL ¶
BaseURL returns the mock endpoint base URL for the Resend REST API. This is the URL you should configure as the Resend API base URL in your client.
Example ¶
ctx := context.Background()
ctr, err := resend.Run(ctx, resend.DefaultImage)
defer func() {
if err := testcontainers.TerminateContainer(ctr); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// baseURL {
baseURL, err := ctr.BaseURL(ctx)
// }
if err != nil {
log.Printf("failed to get base URL: %s", err)
return
}
fmt.Println(baseURL != "")
Output: true
func (*Container) ServiceName ¶
ServiceName returns the API service name extracted from the OpenAPI spec (e.g. "Resend").
func (*Container) ServiceVersion ¶
ServiceVersion returns the API service version extracted from the OpenAPI spec (e.g. "1.5.0").
type Option ¶
type Option func(*resendOptions) error
Option is a function that configures the Resend module.
func WithSpecURL ¶
WithSpecURL sets a custom URL to fetch the Resend OpenAPI spec from. If the URL is unreachable, the module falls back to the embedded spec.
func (Option) Customize ¶
func (o Option) Customize(*testcontainers.GenericContainerRequest) error
Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.