-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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 #5785 from ack/clc-patches
CLC update: tests and alias
- Loading branch information
Showing
9 changed files
with
98 additions
and
122 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,101 +1,3 @@ | ||
package clc | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
clc "github.com/CenturyLinkCloud/clc-sdk" | ||
lb "github.com/CenturyLinkCloud/clc-sdk/lb" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
// things to test: | ||
// updates name/desc | ||
// toggles status | ||
// created w/o pool | ||
|
||
func TestAccLoadBalancerBasic(t *testing.T) { | ||
var resp lb.LoadBalancer | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckLBDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: testAccCheckLBConfigBasic, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckLBExists("clc_load_balancer.acc_test_lb", &resp), | ||
resource.TestCheckResourceAttr("clc_load_balancer.acc_test_lb", "name", "acc_test_lb"), | ||
resource.TestCheckResourceAttr("clc_load_balancer.acc_test_lb", "data_center", testAccDC), | ||
resource.TestCheckResourceAttr("clc_load_balancer.acc_test_lb", "status", "enabled"), | ||
), | ||
}, | ||
// update simple attrs | ||
resource.TestStep{ | ||
Config: testAccCheckLBConfigNameDesc, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckLBExists("clc_load_balancer.acc_test_lb", &resp), | ||
resource.TestCheckResourceAttr("clc_load_balancer.acc_test_lb", "name", "foobar"), | ||
resource.TestCheckResourceAttr("clc_load_balancer.acc_test_lb", "description", "foobar"), | ||
resource.TestCheckResourceAttr("clc_load_balancer.acc_test_lb", "status", "disabled"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckLBDestroy(s *terraform.State) error { | ||
client := testAccProvider.Meta().(*clc.Client) | ||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "clc_load_balancer" { | ||
continue | ||
} | ||
if _, err := client.LB.Get(testAccDC, rs.Primary.ID); err == nil { | ||
return fmt.Errorf("LB still exists") | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func testAccCheckLBExists(n string, resp *lb.LoadBalancer) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
rs, ok := s.RootModule().Resources[n] | ||
if !ok { | ||
return fmt.Errorf("Not found: %s", n) | ||
} | ||
if rs.Primary.ID == "" { | ||
return fmt.Errorf("No ID is set") | ||
} | ||
client := testAccProvider.Meta().(*clc.Client) | ||
l, err := client.LB.Get(testAccDC, rs.Primary.ID) | ||
if err != nil { | ||
return err | ||
} | ||
if l.ID != rs.Primary.ID { | ||
return fmt.Errorf("LB not found") | ||
} | ||
*resp = *l | ||
return nil | ||
} | ||
} | ||
|
||
const testAccCheckLBConfigBasic = ` | ||
variable "dc" { default = "IL1" } | ||
resource "clc_load_balancer" "acc_test_lb" { | ||
data_center = "${var.dc}" | ||
name = "acc_test_lb" | ||
description = "load balancer test" | ||
status = "enabled" | ||
}` | ||
|
||
const testAccCheckLBConfigNameDesc = ` | ||
variable "dc" { default = "IL1" } | ||
resource "clc_load_balancer" "acc_test_lb" { | ||
data_center = "${var.dc}" | ||
name = "foobar" | ||
description = "foobar" | ||
status = "disabled" | ||
}` | ||
// clc_load_balancer covered by clc_load_balancer_pool tests: resource_clc_load_balancer_pool_test.go |
2 changes: 1 addition & 1 deletion
2
vendor/github.com/CenturyLinkCloud/clc-sdk/api/api.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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