Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do Not Merge] This PR is ony for testing, not to be merged. #280

Closed
wants to merge 13 commits into from
Closed
59 changes: 0 additions & 59 deletions tests/other_test.go

This file was deleted.

63 changes: 55 additions & 8 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
// Use existing resource group
// const resourceGroup = "geretain-test-resources"

var sigDirectory string

// Note: if this is needed again in another module move the code to github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper

// CreateSigKeys generates signature keys for the provided usernames and stores them in the specified output directory.
Expand Down Expand Up @@ -87,11 +85,6 @@ func CreateSigKeys(usernames []string, outputDir string) (string, error) {
}

func TestMain(m *testing.M) {
cwd, err := os.Getwd()
if err != nil {
log.Fatalf("Error getting current working directory: %v", err)
}
sigDirectory = cwd + "/sigs"

os.Exit(m.Run())
}
Expand All @@ -114,7 +107,13 @@ func TestRunHpcsFsCloudExample(t *testing.T) {
func TestRunUpgradeExample(t *testing.T) {
t.Parallel()

usernames := []string{"admin1"}
usernames := []string{"admin-pr"}

cwd, err := os.Getwd()
if err != nil {
log.Fatalf("Error getting current working directory: %v", err)
}
sigDirectory := cwd + "/sigs"

admins, err := CreateSigKeys(usernames, sigDirectory)
if !assert.Nilf(t, err, "Error creating sigkeys: %v", err) {
Expand All @@ -137,3 +136,51 @@ func TestRunUpgradeExample(t *testing.T) {
assert.NotNil(t, output, "Expected some output")
}
}

func TestRunBasicExample(t *testing.T) {
t.Parallel()

options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
Testing: t,
TerraformDir: "examples/basic",
Prefix: "basic",
Region: "us-south",
})

output, err := options.RunTestConsistency()

assert.Nil(t, err, "This should not have errored")
assert.NotNil(t, output, "Expected some output")
}

func TestRunCompleteExample(t *testing.T) {
t.Parallel()

usernames := []string{"admin1"}

cwd, err1 := os.Getwd()
if err1 != nil {
log.Fatalf("Error getting current working directory: %v", err1)
}
sigDirectory := cwd + "/keys"

admins, err := CreateSigKeys(usernames, sigDirectory)
if !assert.Nilf(t, err, "Error creating sigkeys: %v", err) {
log.Fatalf("Error creating sigkeys: %v", err)
}

options := testhelper.TestOptionsDefaultWithVars(&testhelper.TestOptions{
Testing: t,
TerraformDir: "examples/complete",
Prefix: "example-hpcs",
Region: "us-south",
TerraformVars: map[string]interface{}{
"admins": admins,
},
})

output, err := options.RunTestConsistency()

assert.Nil(t, err, "This should not have errored")
assert.NotNil(t, output, "Expected some output")
}