-
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.
feat: live acceptance tests for wired and wireless networks
- Loading branch information
1 parent
3fabd7e
commit c5e5c9e
Showing
3 changed files
with
190 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package config | ||
|
||
const WiredNetworkUid = "ethernet-658f93b6ea49" | ||
const WirelessNetworkUid = "ssid-35e69ecab0c3" |
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,93 @@ | ||
package resource_test | ||
|
||
import ( | ||
"github.com/aruba-uxi/terraform-provider-configuration/test/live/config" | ||
"github.com/aruba-uxi/terraform-provider-configuration/test/live/provider" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/tfversion" | ||
) | ||
|
||
func TestWiredNetworkResource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
TerraformVersionChecks: []tfversion.TerraformVersionCheck{ | ||
// we required terraform 1.7.0 and above for the `removed` block | ||
tfversion.RequireAbove(tfversion.Version1_7_0), | ||
}, | ||
Steps: []resource.TestStep{ | ||
// Creating a wired_network is not allowed | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
resource "uxi_wired_network" "my_wired_network" { | ||
name = "name" | ||
}`, | ||
|
||
ExpectError: regexp.MustCompile( | ||
`(?s)creating a wired_network is not supported; wired_networks can only be\s*imported`, | ||
), | ||
}, | ||
// Importing a wired_network | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
resource "uxi_wired_network" "wired_network_0" { | ||
name = "tf-provider-acceptance-tests-ethernet-0" | ||
} | ||
import { | ||
to = uxi_wired_network.wired_network_0 | ||
id = "` + config.WiredNetworkUid + `" | ||
}`, | ||
|
||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"uxi_wired_network.wired_network_0", | ||
"name", | ||
"tf-provider-acceptance-tests-ethernet-0", | ||
), | ||
resource.TestCheckResourceAttr( | ||
"uxi_wired_network.wired_network_0", | ||
"id", | ||
config.WiredNetworkUid, | ||
), | ||
), | ||
}, | ||
// ImportState testing | ||
{ | ||
ResourceName: "uxi_wired_network.wired_network_0", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
// Updating a wired_network is not allowed | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
resource "uxi_wired_network" "wired_network_0" { | ||
name = "tf-provider-acceptance-tests-ethernet-0-updated-name" | ||
}`, | ||
ExpectError: regexp.MustCompile( | ||
`(?s)updating a wired_network is not supported; wired_networks can only be updated\s*through the dashboard`, | ||
), | ||
}, | ||
// Deleting a wired_network is not allowed | ||
{ | ||
Config: provider.ProviderConfig, | ||
ExpectError: regexp.MustCompile( | ||
`(?s)deleting a wired_network is not supported; wired_networks can only removed\s*from state`, | ||
), | ||
}, | ||
// Remove wired_network from state | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
removed { | ||
from = uxi_wired_network.wired_network_0 | ||
lifecycle { | ||
destroy = false | ||
} | ||
}`, | ||
}, | ||
}, | ||
}) | ||
} |
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,93 @@ | ||
package resource_test | ||
|
||
import ( | ||
"github.com/aruba-uxi/terraform-provider-configuration/test/live/config" | ||
"github.com/aruba-uxi/terraform-provider-configuration/test/live/provider" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-testing/tfversion" | ||
) | ||
|
||
func TestWirelessNetworkResource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
TerraformVersionChecks: []tfversion.TerraformVersionCheck{ | ||
// we required terraform 1.7.0 and above for the `removed` block | ||
tfversion.RequireAbove(tfversion.Version1_7_0), | ||
}, | ||
Steps: []resource.TestStep{ | ||
// Creating a wireless_network is not allowed | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
resource "uxi_wireless_network" "wireless_network_0" { | ||
name = "name" | ||
}`, | ||
|
||
ExpectError: regexp.MustCompile( | ||
`(?s)creating a wireless_network is not supported; wireless_networks can only be\s*imported`, | ||
), | ||
}, | ||
// Importing a wireless_network | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
resource "uxi_wireless_network" "wireless_network_0" { | ||
name = "tf-provider-acceptance-tests-ssid-0" | ||
} | ||
import { | ||
to = uxi_wireless_network.wireless_network_0 | ||
id = "` + config.WirelessNetworkUid + `" | ||
}`, | ||
|
||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr( | ||
"uxi_wireless_network.wireless_network_0", | ||
"name", | ||
"tf-provider-acceptance-tests-ssid-0", | ||
), | ||
resource.TestCheckResourceAttr( | ||
"uxi_wireless_network.wireless_network_0", | ||
"id", | ||
config.WirelessNetworkUid, | ||
), | ||
), | ||
}, | ||
// ImportState testing | ||
{ | ||
ResourceName: "uxi_wireless_network.wireless_network_0", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
// Updating a wireless_network is not allowed | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
resource "uxi_wireless_network" "wireless_network_0" { | ||
name = "tf-provider-acceptance-tests-ssid-0-updated-name" | ||
}`, | ||
ExpectError: regexp.MustCompile( | ||
`(?s)updating a wireless_network is not supported; wireless_networks can only be\s*updated through the dashboard`, | ||
), | ||
}, | ||
// Deleting a wireless_network is not allowed | ||
{ | ||
Config: provider.ProviderConfig + ``, | ||
ExpectError: regexp.MustCompile( | ||
`(?s)deleting a wireless_network is not supported; wireless_networks can only\s*removed from state`, | ||
), | ||
}, | ||
// Remove wireless_network from state | ||
{ | ||
Config: provider.ProviderConfig + ` | ||
removed { | ||
from = uxi_wireless_network.wireless_network_0 | ||
lifecycle { | ||
destroy = false | ||
} | ||
}`, | ||
}, | ||
}, | ||
}) | ||
} |