Documentation
¶
Overview ¶
Package testutil provides utilities for testing the migrator package. It includes helpers for setting up and managing ArangoDB test containers.
Overview ¶
This package provides test utilities that make it easy to write integration tests for the migrator package. It uses testcontainers to spin up real ArangoDB instances for testing.
Usage ¶
import "github.com/FramnkRulez/go-arangodb-migrator/pkg/migrator/testutil" func TestMyMigration(t *testing.T) { ctx := context.Background() // Start ArangoDB container container := testutil.NewArangoDBContainer(ctx, t) defer container.Cleanup(ctx) // Create test database db := container.CreateTestDatabase(ctx, t, "test_db") // Run your tests... }
Requirements ¶
This package requires Docker to be running and the testcontainers-go library. Integration tests should be skipped if Docker is not available.
Index ¶
- type ArangoDBContainer
- func (c *ArangoDBContainer) Cleanup(ctx context.Context) error
- func (c *ArangoDBContainer) CreateTestDatabase(ctx context.Context, t require.TestingT, dbName string) arangodb.Database
- func (c *ArangoDBContainer) GetTestDatabase(ctx context.Context, t require.TestingT, dbName string) arangodb.Database
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArangoDBContainer ¶
type ArangoDBContainer struct { Container testcontainers.Container Client arangodb.Client Endpoint string }
ArangoDBContainer represents an ArangoDB test container
func NewArangoDBContainer ¶
func NewArangoDBContainer(ctx context.Context, t require.TestingT) *ArangoDBContainer
NewArangoDBContainer creates and starts a new ArangoDB container for testing
func (*ArangoDBContainer) Cleanup ¶
func (c *ArangoDBContainer) Cleanup(ctx context.Context) error
Cleanup stops and removes the container
func (*ArangoDBContainer) CreateTestDatabase ¶
func (c *ArangoDBContainer) CreateTestDatabase(ctx context.Context, t require.TestingT, dbName string) arangodb.Database
CreateTestDatabase creates a test database and returns it
func (*ArangoDBContainer) GetTestDatabase ¶
func (c *ArangoDBContainer) GetTestDatabase(ctx context.Context, t require.TestingT, dbName string) arangodb.Database
GetTestDatabase gets an existing database or creates it if it doesn't exist