Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Aug 28, 2023
1 parent a853d80 commit 6b5d098
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions from_dockerfile_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package testcontainers

import (
"context"
"path/filepath"
"testing"

"github.com/docker/docker/api/types"
"github.com/stretchr/testify/assert"
)

func TestBuildImageFromDockerfile(t *testing.T) {
provider, err := NewDockerProvider()
if err != nil {
t.Fatal(err)
}
defer provider.Close()

cli := provider.Client()

ctx := context.Background()

tag, err := provider.BuildImage(ctx, &ContainerRequest{
FromDockerfile: FromDockerfile{
Context: filepath.Join("testdata"),
Dockerfile: "echo.Dockerfile",
Repo: "test-repo",
Tag: "test-tag",
},
})
assert.Nil(t, err)
assert.Equal(t, "test-repo:test-tag", tag)

_, _, err = cli.ImageInspectWithRaw(ctx, tag)
assert.Nil(t, err)

t.Cleanup(func() {
_, err := cli.ImageRemove(ctx, tag, types.ImageRemoveOptions{
Force: true,
PruneChildren: true,
})
if err != nil {
t.Fatal(err)
}
})
}

0 comments on commit 6b5d098

Please sign in to comment.