Skip to content

Commit

Permalink
test: add test for provider host config
Browse files Browse the repository at this point in the history
  • Loading branch information
lbergnehr committed Jan 22, 2025
1 parent 7fd757c commit 5a7ffde
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pkg/terraform/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (

func TestMixin_Build(t *testing.T) {
testcases := []struct {
name string
inputFile string
expectedVersion string
expectedUserAgent string
name string
inputFile string
expectedVersion string
expectedUserAgent string
expectedProviderHost string
}{
{
name: "build with custom config",
Expand All @@ -30,9 +31,10 @@ func TestMixin_Build(t *testing.T) {
expectedUserAgent: "ENV PORTER_TERRAFORM_MIXIN_USER_AGENT_OPT_OUT=\"false\"\nENV AZURE_HTTP_USER_AGENT=\"getporter/porter getporter/terraform/v1.2.3",
},
{
name: "build in airgrapped environment",
inputFile: "testdata/build-input-in-airgapped-env.yaml",
expectedVersion: "https://install.example.com/terraform/1.2.3/terraform_1.2.3_linux_amd64.zip",
name: "build in airgrapped environment",
inputFile: "testdata/build-input-in-airgapped-env.yaml",
expectedVersion: "https://install.example.com/terraform/1.2.3/terraform_1.2.3_linux_amd64.zip",
expectedProviderHost: "https://providers.example.com",
},
}

Expand All @@ -57,6 +59,13 @@ func TestMixin_Build(t *testing.T) {
gotOutput := m.TestContext.GetOutput()
assert.Contains(t, gotOutput, tc.expectedVersion)
assert.Contains(t, gotOutput, tc.expectedUserAgent)

if tc.expectedProviderHost != "" {
assert.Contains(t, gotOutput, tc.expectedProviderHost)
} else {
assert.NotContains(t, gotOutput, "network_mirror")
}

assert.NotContains(t, "{{.", gotOutput, "Not all of the template values were consumed")
})
}
Expand Down

0 comments on commit 5a7ffde

Please sign in to comment.