Skip to content

Commit

Permalink
Merge pull request nutanix#28 from nutanix/28-refactor-test-variables
Browse files Browse the repository at this point in the history
Read credentials by env variables in test
  • Loading branch information
crizstian authored May 7, 2018
2 parents f49fd31 + 87f2d31 commit 2adb673
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 42 deletions.
8 changes: 0 additions & 8 deletions nutanix/data_source_nutanix_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ func TestAccNutanixImageDataSource_basic(t *testing.T) {

func testAccImageDataSourceConfig(r int) string {
return fmt.Sprintf(`
provider "nutanix" {
username = "admin"
password = "Nutanix/1234"
endpoint = "10.5.81.134"
insecure = true
port = 9440
}
resource "nutanix_image" "test" {
name = "CentOS-LAMP-APP.qcow2"
description = "CentOS LAMP - App"
Expand Down
9 changes: 4 additions & 5 deletions nutanix/data_source_nutanix_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import (

func TestAccNutanixSubnetDataSource_basic(t *testing.T) {
rInt := acctest.RandInt()
clusterID := testClusterID()

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccSubnetDataSourceConfig(rInt, clusterID),
Config: testAccSubnetDataSourceConfig(rInt),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.nutanix_subnet.nutanix_subnet", "prefix_length", "24"),
Expand All @@ -29,10 +28,10 @@ func TestAccNutanixSubnetDataSource_basic(t *testing.T) {
})
}

func testAccSubnetDataSourceConfig(r int, clusterID string) string {
func testAccSubnetDataSourceConfig(r int) string {
return fmt.Sprintf(`
variable clusterid {
default = "%s"
default = "000567f3-1921-c722-471d-0cc47ac31055"
}
resource "nutanix_subnet" "test" {
Expand Down Expand Up @@ -66,5 +65,5 @@ resource "nutanix_subnet" "test" {
dhcp_domain_search_list = ["nutanix.com", "calm.io"]
}
`, clusterID, r)
`, r)
}
5 changes: 0 additions & 5 deletions nutanix/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nutanix

import (
"os"
"testing"

"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -33,7 +32,3 @@ func TestProvider_impl(t *testing.T) {

func testAccPreCheck(t *testing.T) {
}

func testClusterID() string {
return os.Getenv("NUTANIX_CLUSTER_ID")
}
8 changes: 0 additions & 8 deletions nutanix/resource_nutanix_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ func testAccCheckNutanixImageDestroy(s *terraform.State) error {

func testAccNutanixImageConfig(r int32) string {
return fmt.Sprintf(`
provider "nutanix" {
username = "admin"
password = "Nutanix/1234"
endpoint = "10.5.81.134"
insecure = true
port = 9440
}
resource "nutanix_image" "test" {
name = "CentOS-LAMP-APP.qcow2"
description = "CentOS LAMP - App"
Expand Down
8 changes: 0 additions & 8 deletions nutanix/resource_nutanix_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ func testAccCheckNutanixSubnetDestroy(s *terraform.State) error {

func testAccNutanixSubnetConfig(r int32) string {
return fmt.Sprintf(`
provider "nutanix" {
username = "admin"
password = "Nutanix/1234"
endpoint = "10.5.81.134"
insecure = true
port = 9440
}
resource "nutanix_subnet" "next-iac-managed" {
# Can I hard code image to be kind image?
# We're going to make this implict in future API releases, so hard coding it is safe on the plugin side
Expand Down
8 changes: 0 additions & 8 deletions nutanix/resource_nutanix_virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ func testAccCheckNutanixVirtualMachineDestroy(s *terraform.State) error {

func testAccNutanixVMConfig(r int) string {
return fmt.Sprint(`
provider "nutanix" {
username = "admin"
password = "Nutanix/1234"
endpoint = "10.5.81.134"
insecure = true
port = 9440
}
### Define Script Local Variables
### This can be used for any manner of things, but is useful for like clusterid, to store a mapping of targets for provisioning
### TODO: Need to make clusters a data source object, such that consumers do not need to manually provision cluster ID
Expand Down

0 comments on commit 2adb673

Please sign in to comment.