Skip to content

kernle32dll/testcontainers-go-canned

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

test GoDoc Go Report Card codecov

testcontainers-go-canned

testcontainers-go-canned is a collection templates for testcontainers-go.

Download:

go get github.com/kernle32dll/testcontainers-go-canned@latest

Detailed documentation can be found on GoDoc.

Compatibility

testcontainers-go-canned is automatically tested against the following:

  • Go 1.17.X, 1.18.X and 1.19.X

Getting started

Kafka

Simply initialize a new cluster via...

import "github.com/kernle32dll/testcontainers-go-canned/kafkatest"

[...]

kafkaCluster, err := kafkatest.NewKafkaCluster(ctx)

...and if done, call...

kafkaCluster.StopCluster(ctx)

For some inspiration, look at the cluster_test.go file, which actually tests integration with franz-go.

Configuration

There are many kafkatest.With[...] option functions, you can use for vararg configuration of the cluster. E.g.:

kafkaCluster, err := kafkatest.NewKafkaCluster(
    ctx,
    kafkatest.WithTLS(true),
)

TLS

Take special note of the kafkatest.WithTLS(true) option, which configures the cluster for full TLS. You can then use kafkaCluster.ClientTLSConfig() function to receive an tls.Config, you can plug into your kafka client like so for example (kgo is franz-go):

seed, err := kafkaCluster.GetKafkaHostAndPort(context.Background())
[...]

client, err := kgo.NewClient(
    kgo.SeedBrokers(seed),
    kgo.DialTLSConfig(kafkaCluster.ClientTLSConfig()),
)

About

A collection of templates for testcontainers-go.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages