add Parameter test

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

Branch: refs/heads/master
Commit: 4eaa1a7417c5d808ef65d7d0b4bf5ffc163049b3
Parents: 9ca4361
Author: David Neuman <david.neuma...@gmail.com>
Authored: Fri Dec 2 15:01:20 2016 -0700
Committer: Dan Kirkwood <dang...@gmail.com>
Committed: Sun Jan 8 21:04:59 2017 -0700

----------------------------------------------------------------------
 .../client/tests/integration/parameter_test.go  | 54 ++++++++++++++++++++
 1 file changed, 54 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/4eaa1a74/traffic_ops/client/tests/integration/parameter_test.go
----------------------------------------------------------------------
diff --git a/traffic_ops/client/tests/integration/parameter_test.go 
b/traffic_ops/client/tests/integration/parameter_test.go
new file mode 100644
index 0000000..0f57045
--- /dev/null
+++ b/traffic_ops/client/tests/integration/parameter_test.go
@@ -0,0 +1,54 @@
+package integration
+
+import (
+       // "encoding/json"
+       "encoding/json"
+       "fmt"
+       "testing"
+
+       traffic_ops 
"github.com/apache/incubator-trafficcontrol/traffic_ops/client"
+)
+
+func TestParameters(t *testing.T) {
+       profile, err := GetProfile()
+       if err != nil {
+               t.Errorf("Could not get a profile, error was: %v\n", err)
+       }
+
+       uri := fmt.Sprintf("/api/1.2/parameters/profile/%s.json", profile.Name)
+       resp, err := Request(*to, "GET", uri, nil)
+       if err != nil {
+               t.Errorf("Could not get %s reponse was: %v\n", uri, err)
+               t.FailNow()
+       }
+
+       defer resp.Body.Close()
+       var apiParamRes traffic_ops.ParamResponse
+       if err := json.NewDecoder(resp.Body).Decode(&apiParamRes); err != nil {
+               t.Errorf("Could not decode parameter json.  Error is: %v\n", 
err)
+               t.FailNow()
+       }
+       apiParams := apiParamRes.Response
+
+       clientParams, err := to.Parameters(profile.Name)
+       if err != nil {
+               t.Errorf("Could not get Hardware from client.  Error is: %v\n", 
err)
+               t.FailNow()
+       }
+
+       if len(apiParams) != len(clientParams) {
+               t.Errorf("Params Response Length -- expected %v, got %v\n", 
len(apiParams), len(clientParams))
+       }
+
+       for _, apiParam := range apiParams {
+               match := false
+               for _, clientParam := range clientParams {
+                       if apiParam.Name == clientParam.Name && apiParam.Value 
== clientParam.Value && apiParam.ConfigFile == clientParam.ConfigFile {
+                               match = true
+                       }
+               }
+               if !match {
+                       t.Errorf("Did not get a param matching %+v from the 
client\n", apiParam)
+               }
+       }
+}

Reply via email to