Skip to content

Commit

Permalink
Merge pull request #44 from MissionCriticalCloud/skip_tests_missing_e…
Browse files Browse the repository at this point in the history
…xported_vars

Make acc testing variables optional
  • Loading branch information
ddegoede authored Feb 28, 2019
2 parents c2c85e5 + f84e97c commit aae6ce4
Show file tree
Hide file tree
Showing 18 changed files with 388 additions and 28 deletions.
28 changes: 0 additions & 28 deletions cosmic/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,11 @@ func testAccPreCheck(t *testing.T) {
if v := os.Getenv("COSMIC_SECRET_KEY"); v == "" {
t.Fatal("COSMIC_SECRET_KEY must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_DISK_OFFERING_1"); v == "" {
t.Fatal("COSMIC_DISK_OFFERING_1 must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_DISK_OFFERING_2"); v == "" {
t.Fatal("COSMIC_DISK_OFFERING_2 must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_SERVICE_OFFERING_1"); v == "" {
t.Fatal("COSMIC_SERVICE_OFFERING_1 must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_SERVICE_OFFERING_2"); v == "" {
t.Fatal("COSMIC_SERVICE_OFFERING_2 must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_VPC_ID"); v == "" {
t.Fatal("COSMIC_VPC_ID must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_VPC_OFFERING"); v == "" {
t.Fatal("COSMIC_VPC_OFFERING must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_VPC_NETWORK_OFFERING"); v == "" {
t.Fatal("COSMIC_VPC_NETWORK_OFFERING must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_TEMPLATE"); v == "" {
t.Fatal("COSMIC_TEMPLATE must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_PROJECT_NAME"); v == "" {
t.Fatal("COSMIC_PROJECT_NAME must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_ZONE"); v == "" {
t.Fatal("COSMIC_ZONE must be set for acceptance tests")
}
if v := os.Getenv("COSMIC_DEFAULT_ALLOW_ACL_ID"); v == "" {
t.Fatal("COSMIC_DEFAULT_ALLOW_ACL_ID must be set for acceptance tests")
}
}

// Name of a valid disk offering
Expand Down
60 changes: 60 additions & 0 deletions cosmic/resource_cosmic_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
)

func TestAccCosmicDisk_basic(t *testing.T) {
if COSMIC_DISK_OFFERING_1 == "" {
t.Skip("This test requires an existing disk offering (set it by exporting COSMIC_DISK_OFFERING_1)")
}

var disk cosmic.Volume

resource.Test(t, resource.TestCase{
Expand All @@ -30,6 +34,10 @@ func TestAccCosmicDisk_basic(t *testing.T) {
}

func TestAccCosmicDisk_update(t *testing.T) {
if COSMIC_DISK_OFFERING_1 == "" {
t.Skip("This test requires an existing disk offering (set it by exporting COSMIC_DISK_OFFERING_1)")
}

var disk cosmic.Volume

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -62,6 +70,26 @@ func TestAccCosmicDisk_update(t *testing.T) {
}

func TestAccCosmicDisk_attachBasic(t *testing.T) {
if COSMIC_DISK_OFFERING_1 == "" {
t.Skip("This test requires an existing disk offering (set it by exporting COSMIC_DISK_OFFERING_1)")
}

if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var disk cosmic.Volume

resource.Test(t, resource.TestCase{
Expand All @@ -82,6 +110,22 @@ func TestAccCosmicDisk_attachBasic(t *testing.T) {
}

func TestAccCosmicDisk_attachUpdate(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var disk cosmic.Volume

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -114,6 +158,22 @@ func TestAccCosmicDisk_attachUpdate(t *testing.T) {
}

func TestAccCosmicDisk_attachDeviceID(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var disk cosmic.Volume

resource.Test(t, resource.TestCase{
Expand Down
104 changes: 104 additions & 0 deletions cosmic/resource_cosmic_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@ import (
)

func TestAccCosmicInstance_basic(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_SERVICE_OFFERING_2 == "" {
t.Skip("This test requires a second existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_2)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var instance cosmic.VirtualMachine

resource.Test(t, resource.TestCase{
Expand All @@ -32,6 +52,26 @@ func TestAccCosmicInstance_basic(t *testing.T) {
}

func TestAccCosmicInstance_update(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_SERVICE_OFFERING_2 == "" {
t.Skip("This test requires a second existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_2)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var instance cosmic.VirtualMachine

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -69,6 +109,26 @@ func TestAccCosmicInstance_update(t *testing.T) {
}

func TestAccCosmicInstance_fixedIP(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_SERVICE_OFFERING_2 == "" {
t.Skip("This test requires a second existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_2)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var instance cosmic.VirtualMachine

resource.Test(t, resource.TestCase{
Expand All @@ -90,6 +150,26 @@ func TestAccCosmicInstance_fixedIP(t *testing.T) {
}

func TestAccCosmicInstance_keyPair(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_SERVICE_OFFERING_2 == "" {
t.Skip("This test requires a second existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_2)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var instance cosmic.VirtualMachine

resource.Test(t, resource.TestCase{
Expand All @@ -111,6 +191,30 @@ func TestAccCosmicInstance_keyPair(t *testing.T) {
}

func TestAccCosmicInstance_project(t *testing.T) {
if COSMIC_PROJECT_NAME == "" {
t.Skip("This test requires an existing project (set it by exporting COSMIC_PROJECT_NAME)")
}

if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_SERVICE_OFFERING_2 == "" {
t.Skip("This test requires a second existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_2)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var instance cosmic.VirtualMachine

resource.Test(t, resource.TestCase{
Expand Down
8 changes: 8 additions & 0 deletions cosmic/resource_cosmic_ipaddress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
)

func TestAccCosmicIPAddress_basic(t *testing.T) {
if COSMIC_DEFAULT_ALLOW_ACL_ID == "" {
t.Skip("This test requires a \"default_allow\" ACL ID (set it by exporting COSMIC_DEFAULT_ALLOW_ACL_ID)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

var ipaddr cosmic.PublicIpAddress

resource.Test(t, resource.TestCase{
Expand Down
40 changes: 40 additions & 0 deletions cosmic/resource_cosmic_loadbalancer_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ import (
)

func TestAccCosmicLoadBalancerRule_basic(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_DEFAULT_ALLOW_ACL_ID == "" {
t.Skip("This test requires a \"default_allow\" ACL ID (set it by exporting COSMIC_DEFAULT_ALLOW_ACL_ID)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -35,6 +55,26 @@ func TestAccCosmicLoadBalancerRule_basic(t *testing.T) {
}

func TestAccCosmicLoadBalancerRule_update(t *testing.T) {
if COSMIC_SERVICE_OFFERING_1 == "" {
t.Skip("This test requires an existing service offering (set it by exporting COSMIC_SERVICE_OFFERING_1)")
}

if COSMIC_TEMPLATE == "" {
t.Skip("This test requires an existing instance template (set it by exporting COSMIC_TEMPLATE)")
}

if COSMIC_DEFAULT_ALLOW_ACL_ID == "" {
t.Skip("This test requires a \"default_allow\" ACL ID (set it by exporting COSMIC_DEFAULT_ALLOW_ACL_ID)")
}

if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

if COSMIC_VPC_NETWORK_OFFERING == "" {
t.Skip("This test requires an existing VPC network offering (set it by exporting COSMIC_VPC_NETWORK_OFFERING)")
}

var id string

resource.Test(t, resource.TestCase{
Expand Down
8 changes: 8 additions & 0 deletions cosmic/resource_cosmic_network_acl_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import (
)

func TestAccCosmicNetworkACLRule_basic(t *testing.T) {
if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down Expand Up @@ -83,6 +87,10 @@ func TestAccCosmicNetworkACLRule_basic(t *testing.T) {
}

func TestAccCosmicNetworkACLRule_update(t *testing.T) {
if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down
4 changes: 4 additions & 0 deletions cosmic/resource_cosmic_network_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
)

func TestAccCosmicNetworkACL_basic(t *testing.T) {
if COSMIC_VPC_ID == "" {
t.Skip("This test requires an existing VPC ID (set it by exporting COSMIC_VPC_ID)")
}

var acl cosmic.NetworkACLList
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
Loading

0 comments on commit aae6ce4

Please sign in to comment.