Adding ability to list LB algorithms
diff --git a/rackspace/lb/v1/lbs/requests_test.go b/rackspace/lb/v1/lbs/requests_test.go
index 033cd7f..fa1e658 100644
--- a/rackspace/lb/v1/lbs/requests_test.go
+++ b/rackspace/lb/v1/lbs/requests_test.go
@@ -34,7 +34,7 @@
ID: 71,
Protocol: "HTTP",
Port: 80,
- Algorithm: RAND,
+ Algorithm: "RANDOM",
Status: ACTIVE,
NodeCount: 3,
VIPs: []vips.VIP{
@@ -87,7 +87,7 @@
Protocol: "HTTP",
HalfClosed: false,
Port: 83,
- Algorithm: RAND,
+ Algorithm: "RANDOM",
Status: BUILD,
Timeout: 30,
Cluster: Cluster{Name: "ztm-n01.staging1.lbaas.rackspace.net"},
@@ -158,7 +158,7 @@
ID: 2000,
Protocol: "HTTP",
Port: 80,
- Algorithm: RAND,
+ Algorithm: "RANDOM",
Status: ACTIVE,
Timeout: 30,
ConnectionLogging: ConnectionLogging{Enabled: true},
@@ -217,7 +217,7 @@
Name: "a-new-loadbalancer",
Protocol: "TCP",
HalfClosed: Enabled,
- Algorithm: RAND,
+ Algorithm: "RANDOM",
Port: 8080,
Timeout: 100,
HTTPSRedirect: Disabled,
@@ -258,3 +258,33 @@
th.AssertNoErr(t, err)
th.AssertEquals(t, 1, count)
}
+
+func TestListAlgorithms(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ mockListAlgorithmsResponse(t)
+
+ count := 0
+
+ err := ListAlgorithms(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
+ count++
+ actual, err := ExtractAlgorithms(page)
+ th.AssertNoErr(t, err)
+
+ expected := []Algorithm{
+ Algorithm{Name: "LEAST_CONNECTIONS"},
+ Algorithm{Name: "RANDOM"},
+ Algorithm{Name: "ROUND_ROBIN"},
+ Algorithm{Name: "WEIGHTED_LEAST_CONNECTIONS"},
+ Algorithm{Name: "WEIGHTED_ROUND_ROBIN"},
+ }
+
+ th.CheckDeepEquals(t, expected, actual)
+
+ return true, nil
+ })
+
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, 1, count)
+}