-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
- Loading branch information
1 parent
d773ef4
commit f5a58f1
Showing
4 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,48 @@ | ||
package terraform | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMixin_Build(t *testing.T) { | ||
m := NewTestMixin(t) | ||
|
||
err := m.Build() | ||
require.NoError(t, err) | ||
|
||
wantOutput := `ENV TERRAFORM_VERSION=0.12.17 | ||
const buildOutputTemplate = `ENV TERRAFORM_VERSION=%s | ||
RUN apt-get update && apt-get install -y wget unzip && \ | ||
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \ | ||
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/bin | ||
COPY . $BUNDLE_DIR | ||
RUN cd /cnab/app/terraform && terraform init -backend=false | ||
` | ||
|
||
gotOutput := m.TestContext.GetOutput() | ||
assert.Equal(t, wantOutput, gotOutput) | ||
func TestMixin_Build(t *testing.T) { | ||
t.Run("build with the default Terraform version", func(t *testing.T) { | ||
m := NewTestMixin(t) | ||
|
||
err := m.Build() | ||
require.NoError(t, err) | ||
|
||
wantOutput := fmt.Sprintf(buildOutputTemplate, "0.12.17") | ||
|
||
gotOutput := m.TestContext.GetOutput() | ||
assert.Equal(t, wantOutput, gotOutput) | ||
}) | ||
|
||
t.Run("build with custom Terrafrom version", func(t *testing.T) { | ||
b, err := ioutil.ReadFile("testdata/build-input-with-version.yaml") | ||
require.NoError(t, err) | ||
|
||
m := NewTestMixin(t) | ||
m.In = bytes.NewReader(b) | ||
err = m.Build() | ||
require.NoError(t, err) | ||
|
||
wantOutput := fmt.Sprintf(buildOutputTemplate, "0.13.0-rc1") | ||
|
||
gotOutput := m.TestContext.GetOutput() | ||
assert.Equal(t, wantOutput, gotOutput) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
config: | ||
clientVersion: 0.13.0-rc1 | ||
install: | ||
- terraform: | ||
description: "noop" |