You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2016/11/28 21:23:02 UTC

[04/11] incubator-trafficcontrol git commit: update hardware client for psql

update hardware client for psql


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/09d6bdfe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/09d6bdfe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/09d6bdfe

Branch: refs/heads/psql-rebase
Commit: 09d6bdfe8c07591bc1dbcdf8a7ef3f8e7bbeb994
Parents: 028ac96
Author: David Neuman <da...@gmail.com>
Authored: Tue Nov 22 11:05:17 2016 -0700
Committer: David Neuman <da...@gmail.com>
Committed: Tue Nov 22 11:05:17 2016 -0700

----------------------------------------------------------------------
 traffic_ops/client/fixtures/hardware.go   |  2 +-
 traffic_ops/client/hardware.go            | 10 +++++++---
 traffic_ops/client/tests/hardware_test.go |  4 ++--
 3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/09d6bdfe/traffic_ops/client/fixtures/hardware.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/fixtures/hardware.go b/traffic_ops/client/fixtures/hardware.go
index a7069a2..74c4a36 100644
--- a/traffic_ops/client/fixtures/hardware.go
+++ b/traffic_ops/client/fixtures/hardware.go
@@ -22,7 +22,7 @@ func Hardware() *client.HardwareResponse {
 	return &client.HardwareResponse{
 		Response: []client.Hardware{
 			client.Hardware{
-				ID:          "18",
+				ID:          18,
 				HostName:    "odol-atsmid-cen-09",
 				LastUpdated: "2015-07-16 09:04:20",
 				Value:       "1.00",

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/09d6bdfe/traffic_ops/client/hardware.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/hardware.go b/traffic_ops/client/hardware.go
index 939ce12..1fef498 100644
--- a/traffic_ops/client/hardware.go
+++ b/traffic_ops/client/hardware.go
@@ -16,16 +16,17 @@
 package client
 
 import "encoding/json"
+import "fmt"
 
 // HardwareResponse ...
 type HardwareResponse struct {
-	Version  string     `json:"version"`
+	Limit    int        `json:"limit"`
 	Response []Hardware `json:"response"`
 }
 
 // Hardware ...
 type Hardware struct {
-	ID          string `json:"serverId"`
+	ID          int    `json:"serverId"`
 	HostName    string `json:"serverHostName"`
 	LastUpdated string `json:"lastUpdated"`
 	Value       string `json:"val"`
@@ -33,8 +34,11 @@ type Hardware struct {
 }
 
 // Hardware gets an array of Hardware
-func (to *Session) Hardware() ([]Hardware, error) {
+func (to *Session) Hardware(limit int) ([]Hardware, error) {
 	url := "/api/1.2/hwinfo.json"
+	if limit > 0 {
+		url += fmt.Sprintf("?limit=%v", limit)
+	}
 	resp, err := to.request("GET", url, nil)
 	if err != nil {
 		return nil, err

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/09d6bdfe/traffic_ops/client/tests/hardware_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/tests/hardware_test.go b/traffic_ops/client/tests/hardware_test.go
index 140601a..58a042c 100644
--- a/traffic_ops/client/tests/hardware_test.go
+++ b/traffic_ops/client/tests/hardware_test.go
@@ -37,7 +37,7 @@ func TestHardware(t *testing.T) {
 
 	testHelper.Context(t, "Given the need to test a successful Traffic Ops request for Hardware")
 
-	hardware, err := to.Hardware()
+	hardware, err := to.Hardware(0)
 	if err != nil {
 		testHelper.Error(t, "Should be able to make a request to Traffic Ops")
 	} else {
@@ -83,7 +83,7 @@ func TestHardwareUnauthorized(t *testing.T) {
 
 	testHelper.Context(t, "Given the need to test a failed Traffic Ops request for Hardware")
 
-	_, err := to.Hardware()
+	_, err := to.Hardware(0)
 	if err == nil {
 		testHelper.Error(t, "Should not be able to make a request to Traffic Ops")
 	} else {