2014-12-10 22:20:52 +01:00
|
|
|
package cloudstack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
|
|
|
var testAccProviders map[string]terraform.ResourceProvider
|
|
|
|
var testAccProvider *schema.Provider
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
testAccProvider = Provider().(*schema.Provider)
|
|
|
|
testAccProviders = map[string]terraform.ResourceProvider{
|
|
|
|
"cloudstack": testAccProvider,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestProvider(t *testing.T) {
|
|
|
|
if err := Provider().(*schema.Provider).InternalValidate(); err != nil {
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestProvider_impl(t *testing.T) {
|
|
|
|
var _ terraform.ResourceProvider = Provider()
|
|
|
|
}
|
|
|
|
|
2015-04-29 11:21:37 +02:00
|
|
|
func testSetValueOnResourceData(t *testing.T) {
|
|
|
|
d := schema.ResourceData{}
|
|
|
|
d.Set("id", "name")
|
|
|
|
|
|
|
|
setValueOrUUID(&d, "id", "name", "54711781-274e-41b2-83c0-17194d0108f7")
|
|
|
|
|
|
|
|
if d.Get("id").(string) != "name" {
|
|
|
|
t.Fatal("err: 'id' does not match 'name'")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testSetUuidOnResourceData(t *testing.T) {
|
|
|
|
d := schema.ResourceData{}
|
|
|
|
d.Set("id", "54711781-274e-41b2-83c0-17194d0108f7")
|
|
|
|
|
|
|
|
setValueOrUUID(&d, "id", "name", "54711781-274e-41b2-83c0-17194d0108f7")
|
|
|
|
|
|
|
|
if d.Get("id").(string) != "54711781-274e-41b2-83c0-17194d0108f7" {
|
|
|
|
t.Fatal("err: 'id' doest not match '54711781-274e-41b2-83c0-17194d0108f7'")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-10 22:20:52 +01:00
|
|
|
func testAccPreCheck(t *testing.T) {
|
|
|
|
if v := os.Getenv("CLOUDSTACK_API_URL"); v == "" {
|
|
|
|
t.Fatal("CLOUDSTACK_API_URL must be set for acceptance tests")
|
|
|
|
}
|
|
|
|
if v := os.Getenv("CLOUDSTACK_API_KEY"); v == "" {
|
|
|
|
t.Fatal("CLOUDSTACK_API_KEY must be set for acceptance tests")
|
|
|
|
}
|
|
|
|
if v := os.Getenv("CLOUDSTACK_SECRET_KEY"); v == "" {
|
|
|
|
t.Fatal("CLOUDSTACK_SECRET_KEY must be set for acceptance tests")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-15 10:04:09 +01:00
|
|
|
// SET THESE VALUES IN ORDER TO RUN THE ACC TESTS!!
|
2015-05-05 11:37:23 +02:00
|
|
|
var CLOUDSTACK_2ND_NIC_IPADDRESS = ""
|
|
|
|
var CLOUDSTACK_2ND_NIC_NETWORK = ""
|
2014-12-10 22:20:52 +01:00
|
|
|
var CLOUDSTACK_DISK_OFFERING_1 = ""
|
|
|
|
var CLOUDSTACK_DISK_OFFERING_2 = ""
|
2015-04-11 17:50:06 +02:00
|
|
|
var CLOUDSTACK_HYPERVISOR = ""
|
2014-12-10 22:20:52 +01:00
|
|
|
var CLOUDSTACK_SERVICE_OFFERING_1 = ""
|
|
|
|
var CLOUDSTACK_SERVICE_OFFERING_2 = ""
|
|
|
|
var CLOUDSTACK_NETWORK_1 = ""
|
|
|
|
var CLOUDSTACK_NETWORK_1_IPADDRESS = ""
|
|
|
|
var CLOUDSTACK_NETWORK_2 = ""
|
2015-05-05 11:37:23 +02:00
|
|
|
var CLOUDSTACK_NETWORK_2_CIDR = ""
|
|
|
|
var CLOUDSTACK_NETWORK_2_OFFERING = ""
|
2014-12-10 22:20:52 +01:00
|
|
|
var CLOUDSTACK_NETWORK_2_IPADDRESS = ""
|
2015-03-09 14:00:29 +01:00
|
|
|
var CLOUDSTACK_VPC_CIDR_1 = ""
|
|
|
|
var CLOUDSTACK_VPC_CIDR_2 = ""
|
2014-12-10 22:20:52 +01:00
|
|
|
var CLOUDSTACK_VPC_OFFERING = ""
|
|
|
|
var CLOUDSTACK_VPC_NETWORK_CIDR = ""
|
|
|
|
var CLOUDSTACK_VPC_NETWORK_OFFERING = ""
|
|
|
|
var CLOUDSTACK_PUBLIC_IPADDRESS = ""
|
2015-05-07 16:10:57 +02:00
|
|
|
var CLOUDSTACK_SSH_KEYPAIR = ""
|
|
|
|
var CLOUDSTACK_SSH_PUBLIC_KEY = ""
|
2014-12-10 22:20:52 +01:00
|
|
|
var CLOUDSTACK_TEMPLATE = ""
|
2015-04-11 17:50:06 +02:00
|
|
|
var CLOUDSTACK_TEMPLATE_FORMAT = ""
|
2015-03-18 11:11:56 +01:00
|
|
|
var CLOUDSTACK_TEMPLATE_URL = ""
|
|
|
|
var CLOUDSTACK_TEMPLATE_OS_TYPE = ""
|
2015-04-11 17:50:06 +02:00
|
|
|
var CLOUDSTACK_ZONE = ""
|