-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
182 additions
and
0 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
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,18 @@ | ||
package atmos | ||
|
||
import ( | ||
"github.com/gruntwork-io/terratest/modules/testing" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Vendor runs atmos vendor with the given options and return stdout/stderr. | ||
func VendorPull(t testing.TestingT, options *Options) string { | ||
out, err := VendorPullE(t, options) | ||
require.NoError(t, err) | ||
return out | ||
} | ||
|
||
// VendorPullE runs atmos vendor with the given options and return stdout/stderr. | ||
func VendorPullE(t testing.TestingT, options *Options) (string, error) { | ||
return RunAtmosCommandE(t, options, FormatArgs(options, "vendor", "pull")...) | ||
} |
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,90 @@ | ||
package atmos | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/gruntwork-io/terratest/modules/files" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func setupVendorTest(t *testing.T) (string, func()) { | ||
testFolder, err := files.CopyTerraformFolderToTemp(atmosExamplePath, t.Name()) | ||
require.NoError(t, err, "Failed to copy Terraform folder to temp directory") | ||
|
||
cleanup := func() { | ||
os.RemoveAll(testFolder) | ||
} | ||
|
||
return testFolder, cleanup | ||
} | ||
|
||
func TestVendorPullBasic(t *testing.T) { | ||
t.Parallel() | ||
|
||
testFolder, cleanup := setupVendorTest(t) | ||
defer cleanup() | ||
|
||
fmt.Printf("running in %s\n", testFolder) | ||
|
||
options := WithDefaultRetryableErrors(t, &Options{ | ||
AtmosBasePath: testFolder, | ||
}) | ||
|
||
_, err := VendorPullE(t, options) | ||
require.NoError(t, err) | ||
|
||
_, err = os.Stat(filepath.Join(testFolder, "components", "terraform", "vpc")) | ||
require.NoError(t, err) | ||
|
||
_, err = os.Stat(filepath.Join(testFolder, "components", "terraform", "vpc-flow-logs-bucket")) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestVendorPullSingleComponent(t *testing.T) { | ||
t.Parallel() | ||
|
||
testFolder, cleanup := setupVendorTest(t) | ||
defer cleanup() | ||
|
||
fmt.Printf("running in %s\n", testFolder) | ||
|
||
options := WithDefaultRetryableErrors(t, &Options{ | ||
AtmosBasePath: testFolder, | ||
VendorComponent: "vpc", | ||
}) | ||
|
||
_, err := VendorPullE(t, options) | ||
require.NoError(t, err) | ||
|
||
_, err = os.Stat(filepath.Join(testFolder, "components", "terraform", "vpc")) | ||
require.NoError(t, err) | ||
|
||
_, err = os.Stat(filepath.Join(testFolder, "components", "terraform", "vpc-flow-logs-bucket")) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestVendorPullByTag(t *testing.T) { | ||
t.Parallel() | ||
|
||
testFolder, cleanup := setupVendorTest(t) | ||
defer cleanup() | ||
|
||
fmt.Printf("running in %s\n", testFolder) | ||
|
||
options := WithDefaultRetryableErrors(t, &Options{ | ||
AtmosBasePath: testFolder, | ||
VendorTags: []string{"storage"}, | ||
}) | ||
|
||
_, err := VendorPullE(t, options) | ||
require.NoError(t, err) | ||
|
||
_, err = os.Stat(filepath.Join(testFolder, "components", "terraform", "vpc")) | ||
require.Error(t, err) | ||
|
||
_, err = os.Stat(filepath.Join(testFolder, "components", "terraform", "vpc-flow-logs-bucket")) | ||
require.NoError(t, err) | ||
} |
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,32 @@ | ||
apiVersion: atmos/v1 | ||
kind: AtmosVendorConfig | ||
metadata: | ||
name: test-vendor-config | ||
description: Atmos vendoring manifest for testing | ||
spec: | ||
# `imports` or `sources` (or both) must be defined in a vendoring manifest | ||
imports: [] | ||
|
||
sources: | ||
- component: "vpc" | ||
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc?ref={{.Version}}" | ||
version: "1.398.0" | ||
targets: | ||
- "components/terraform/vpc" | ||
included_paths: | ||
- "**/*.tf" | ||
excluded_paths: | ||
- "**/providers.tf" | ||
tags: | ||
- networking | ||
- component: "vpc-flow-logs-bucket" | ||
source: "github.com/cloudposse/terraform-aws-components.git//modules/vpc-flow-logs-bucket?ref={{.Version}}" | ||
version: "1.398.0" | ||
targets: | ||
- "components/terraform/vpc-flow-logs-bucket" | ||
included_paths: | ||
- "**/*.tf" | ||
excluded_paths: | ||
- "**/providers.tf" | ||
tags: | ||
- storage |