I’m having trouble figuring out what’s going wrong here because no matter what I put in the test values it passes:
package redfish
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"testing"
)
// redfish.Power represents a concrete Go type that represents an API resource
func TestAccRedfishPower_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccRedfishResourcePowerConfig("root",
"password",
"root",
"password",
"192.168.1.63",
"PowerOn",
120,
10),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("nonsense", "complete_nonsense", "supernonsense"),
),
},
},
})
}
func testAccRedfishResourcePowerConfig(providerUsername string,
providerPassword string,
serverUsername string,
serverPassword string,
serverEndpoint string,
desiredPowerAction string,
maximumWaitTime int,
checkInterval int) string {
return fmt.Sprintf(`
terraform {
required_providers {
redfish = {
source = "grantcurell/redfish"
}
}
}
// For servers without a uniquely defined username/password these values will be used
provider "redfish" {
user = "%s"
password = "%s"
}
resource "redfish_power" "system_power" {
redfish_server {
user = "%s"
password = "%s"
endpoint = "https://%s"
ssl_insecure = true
}
desired_power_action = "%s"
maximum_wait_time = %d
check_interval = %d
}
output "current_power_state" {
value = redfish_power.system_power
}
`,
providerUsername, providerPassword, serverUsername,
serverPassword, serverEndpoint, desiredPowerAction,
maximumWaitTime, checkInterval,
)
}
I only have this one test and when I run it I get:
go test
PASS
ok github.com/grantcurell/terraform-provider-redfish/redfish 0.136s
The provider test is:
package redfish
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
var testAccProviders map[string]*schema.Provider
var testAccProvider *schema.Provider
func init() {
testAccProvider = Provider()
testAccProviders = map[string]*schema.Provider{
"redfish": testAccProvider,
}
}
Is there something obvious I’m missing?