-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from nutanix/test/karbon
Add testacc for karbon resources and data sources
- Loading branch information
Showing
6 changed files
with
519 additions
and
1 deletion.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
nutanix/data_source_nutanix_karbon_cluster_kubeconfig_test.go
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,67 @@ | ||
package nutanix | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccNutanixKarbonClusterKubeConfigDataSource_basic(t *testing.T) { | ||
r := acctest.RandInt() | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClusterKubeConfigDataSourceConfig(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_cluster_kubeconfig.config", "id"), | ||
resource.TestCheckResourceAttr( | ||
"data.nutanix_karbon_cluster_kubeconfig.config", "karbon_cluster_name", fmt.Sprintf("test-karbon-%d", r)), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccNutanixKarbonClusterKubeConfigDataSource_basicByName(t *testing.T) { | ||
r := acctest.RandInt() | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClusterKubeConfigDataSourceConfigByName(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_cluster_kubeconfig.config", "id"), | ||
resource.TestCheckResourceAttr( | ||
"data.nutanix_karbon_cluster_kubeconfig.config", "karbon_cluster_name", fmt.Sprintf("test-karbon-%d", r)), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccKarbonClusterKubeConfigDataSourceConfig(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_cluster_kubeconfig" "config" { | ||
karbon_cluster_id = nutanix_karbon_cluster.cluster.id | ||
} | ||
` | ||
} | ||
|
||
func testAccKarbonClusterKubeConfigDataSourceConfigByName(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_cluster_kubeconfig" "config" { | ||
karbon_cluster_name = nutanix_karbon_cluster.cluster.name | ||
} | ||
` | ||
} |
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,68 @@ | ||
package nutanix | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccNutanixKarbonClusterSSHDataSource_basicx(t *testing.T) { | ||
r := acctest.RandInt() | ||
//resourceName := "nutanix_karbon_cluster.cluster" | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClusterSSHDataSourceConfig(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_cluster_ssh.ssh", "id"), | ||
resource.TestCheckResourceAttr( | ||
"data.nutanix_karbon_cluster_ssh.ssh", "username", "admin"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccNutanixKarbonClusterSSHDataSource_basicByName(t *testing.T) { | ||
r := acctest.RandInt() | ||
//resourceName := "nutanix_karbon_cluster.cluster" | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClusterSSHDataSourceConfigByName(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_cluster_ssh.ssh", "id"), | ||
resource.TestCheckResourceAttr( | ||
"data.nutanix_karbon_cluster_ssh.ssh", "username", "admin"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccKarbonClusterSSHDataSourceConfig(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_cluster_ssh" "ssh" { | ||
karbon_cluster_id = nutanix_karbon_cluster.cluster.id | ||
} | ||
` | ||
} | ||
|
||
func testAccKarbonClusterSSHDataSourceConfigByName(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_cluster_ssh" "ssh" { | ||
karbon_cluster_name = nutanix_karbon_cluster.cluster.name | ||
} | ||
` | ||
} |
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,65 @@ | ||
package nutanix | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccNutanixKarbonClusterDataSource_basic(t *testing.T) { | ||
r := acctest.RandInt() | ||
dataSourceName := "data.nutanix_karbon_cluster.kcluster" | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClusterDataSourceConfig(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckNutanixKarbonClusterExists(dataSourceName), | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_cluster.kcluster", "id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccNutanixKarbonClusterDataSource_basicByName(t *testing.T) { | ||
r := acctest.RandInt() | ||
//resourceName := "nutanix_karbon_cluster.cluster" | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClusterDataSourceConfigByName(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_cluster.kcluster", "id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccKarbonClusterDataSourceConfig(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_cluster" "kcluster" { | ||
karbon_cluster_id = nutanix_karbon_cluster.cluster.id | ||
} | ||
` | ||
} | ||
|
||
func testAccKarbonClusterDataSourceConfigByName(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_cluster" "kcluster" { | ||
karbon_cluster_name = nutanix_karbon_cluster.cluster.name | ||
} | ||
` | ||
} |
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,35 @@ | ||
package nutanix | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccNutanixKarbonClustersDataSource_basic(t *testing.T) { | ||
r := acctest.RandInt() | ||
//resourceName := "nutanix_karbon_cluster.cluster" | ||
subnetName := "Rx-Automation-Network" | ||
defaultContainter := "default-container-85827904983728" | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccKarbonClustersDataSourceConfig(subnetName, r, defaultContainter, 1), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet( | ||
"data.nutanix_karbon_clusters.kclusters", "clusters.#"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccKarbonClustersDataSourceConfig(subnetName string, r int, containter string, workers int) string { | ||
return testAccNutanixKarbonClusterConfig(subnetName, r, containter, workers, "flannel") + ` | ||
data "nutanix_karbon_clusters" "kclusters" {} | ||
` | ||
} |
Oops, something went wrong.