2025-01-10 19:17:20 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2025-03-04 15:51:03 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2025-01-10 19:17:20 +00:00
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
|
|
|
"github.com/testcontainers/testcontainers-go/network"
|
|
|
|
|
)
|
|
|
|
|
|
2025-02-14 10:56:24 +00:00
|
|
|
func CreateNetwork(t testing.TB, ctx context.Context) (*testcontainers.DockerNetwork, func()) {
|
2025-01-10 19:17:20 +00:00
|
|
|
network, err := network.New(ctx, network.WithDriver("bridge"))
|
2025-03-04 15:51:03 +00:00
|
|
|
require.NoError(t, err)
|
2025-01-10 19:17:20 +00:00
|
|
|
|
|
|
|
|
return network, func() {
|
|
|
|
|
testcontainers.CleanupNetwork(t, network)
|
|
|
|
|
}
|
|
|
|
|
}
|