github.com/darmach/terratest@v0.34.8-0.20210517103231-80931f95e3ff/test/packer_hello_world_example_test.go (about) 1 package test 2 3 import ( 4 "testing" 5 6 "github.com/gruntwork-io/terratest/modules/docker" 7 "github.com/gruntwork-io/terratest/modules/packer" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestPackerHelloWorldExample(t *testing.T) { 12 packerOptions := &packer.Options{ 13 // website::tag::1:: The path to where the Packer template is located 14 Template: "../examples/packer-hello-world-example/build.json", 15 } 16 17 // website::tag::2:: Build the Packer template. This template will create a Docker image. 18 packer.BuildArtifact(t, packerOptions) 19 20 // website::tag::3:: Run the Docker image, read the text file from it, and make sure it contains the expected output. 21 opts := &docker.RunOptions{Command: []string{"cat", "/test.txt"}} 22 output := docker.Run(t, "gruntwork/packer-hello-world-example", opts) 23 assert.Equal(t, "Hello, World!", output) 24 }