Skip to content

Commit

Permalink
rename randomseed to randomidentifier (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalhoun authored Nov 25, 2024
1 parent dfc34d9 commit bd1fd71
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 76 deletions.
65 changes: 0 additions & 65 deletions go.sum

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pkg/atmos/aws-component-helper/atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (

func GetAtmosOptions(t *testing.T, suite *TestSuite, componentName string, stackName string, vars map[string]interface{}) *atmos.Options {
mergedVars := map[string]interface{}{
"attributes": []string{suite.RandomSeed},
"attributes": []string{suite.RandomIdentifier},
"region": suite.AwsRegion,
}

// If we are not skipping the nuking of the test account, add the default tags
if !suite.SkipNukeTestAccount {
nukeVars := map[string]interface{}{
"default_tags": map[string]string{
"CreatedByTerratestRun": suite.RandomSeed,
"CreatedByTerratestRun": suite.RandomIdentifier,
},
}

Expand All @@ -38,7 +38,7 @@ func GetAtmosOptions(t *testing.T, suite *TestSuite, componentName string, stack
Stack: stackName,
NoColor: true,
BackendConfig: map[string]interface{}{
"workspace_key_prefix": strings.Join([]string{suite.RandomSeed, stackName}, "-"),
"workspace_key_prefix": strings.Join([]string{suite.RandomIdentifier, stackName}, "-"),
},
Vars: mergedVars,
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/atmos/aws-component-helper/setup_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func readOrCreateTestSuiteFile(testSuite *TestSuite, testName string) (*TestSuit
return testSuite, nil
} else {
randID := random.UniqueId()
testSuite.RandomSeed = strings.ToLower(randID)
testSuite.RandomIdentifier = strings.ToLower(randID)

testSuite.TempDir, err = os.MkdirTemp("", testName)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/atmos/aws-component-helper/setup_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestReadOrCreateTestSuiteFile(t *testing.T) {

result, err := readOrCreateTestSuiteFile(ts, testName)
assert.NoError(t, err)
assert.NotEmpty(t, result.RandomSeed)
assert.NotEmpty(t, result.RandomIdentifier)
assert.NotEmpty(t, result.TempDir)

// Verify file was created
Expand All @@ -83,8 +83,8 @@ func TestReadOrCreateTestSuiteFile(t *testing.T) {
t.Run("read existing test suite file", func(t *testing.T) {
// Create a test suite file
existingTS := &TestSuite{
RandomSeed: "test-seed",
TempDir: "test-dir",
RandomIdentifier: "test-seed",
TempDir: "test-dir",
}
data, err := json.MarshalIndent(existingTS, "", " ")
assert.NoError(t, err)
Expand All @@ -95,10 +95,10 @@ func TestReadOrCreateTestSuiteFile(t *testing.T) {
ts := &TestSuite{}
result, err := readOrCreateTestSuiteFile(ts, "test_")
assert.NoError(t, err)
assert.Equal(t, existingTS.RandomSeed, result.RandomSeed)
assert.Equal(t, existingTS.RandomIdentifier, result.RandomIdentifier)
assert.Equal(t, existingTS.TempDir, result.TempDir)

// Clean up
os.Remove(testSuiteFile)
})
}
}
2 changes: 1 addition & 1 deletion pkg/atmos/aws-component-helper/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type TestSuite struct {
ComponentSrcPath string
Dependencies []*Dependency
FixturesPath string
RandomSeed string
RandomIdentifier string
SkipSetupComponentUnderTest bool
SkipDeployDependencies bool
SkipDeployComponentUnderTest bool
Expand Down
2 changes: 1 addition & 1 deletion test/aws-component-helper/test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ func TestBasic(t *testing.T) {
require.NoError(t, err)

revision := atmos.Output(t, suite.AtmosOptions, "revision")
expected := fmt.Sprintf("%s-%s", strings.ToLower(suite.RandomSeed), additionalVars["revision"])
expected := fmt.Sprintf("%s-%s", strings.ToLower(suite.RandomIdentifier), additionalVars["revision"])
require.Equal(t, expected, revision)
}

0 comments on commit bd1fd71

Please sign in to comment.