Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.79 KB

README.md

File metadata and controls

46 lines (32 loc) · 1.79 KB

testcontainers-imds

Build status License MIT Go Report Card Go Version DeepSource

Testcontainers wrapper for the Instance Metadata Mock (imds-mock) tool. Quickly and easily simulate the Amazon Instance Metadata Service (IMDS) for localised testing.

Quick Start

Import the library into your project:

go get github.com/purpleclay/testcontainers-imds

Then write your first test:

package imds_test

import (
    "context"
    "testing"

    imds "github.com/purpleclay/testcontainers-imds"
    "github.com/stretchr/testify/assert"
    "github.com/stretchr/testify/require"
)

func TestInstanceMetadata(t *testing.T) {
    ctx := context.Background()

    container, err := imds.Start(ctx)
    require.NoError(t, err)
    defer container.Terminate(ctx)

    ipv4, _, _ := container.Get(imds.PathLocalIPv4)

    assert.Equal(t, imds.ValueLocalIPv4, ipv4)
}

If you need more examples, take a look here.