Repository: incubator-trafficcontrol Updated Branches: refs/heads/psql-rebase 4878822d6 -> deaf0c6b2
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/6c251610 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/6c251610 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/6c251610 Branch: refs/heads/psql-rebase Commit: 6c2516103642de0a4b089a068063a5b304d93b87 Parents: 2e770a8 Author: David Neuman <david.neuma...@gmail.com> Authored: Fri Dec 2 15:01:20 2016 -0700 Committer: Dave Neuman <neu...@apache.org> Committed: Fri Dec 2 15:22:55 2016 -0700 ---------------------------------------------------------------------- .../client/tests/integration/parameter_test.go | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6c251610/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) + } + } +}