update Type struct to return ID. Updated test to check for ID and UseInTable
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/21697fe9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/21697fe9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/21697fe9 Branch: refs/heads/psql-rebase Commit: 21697fe9a0ac919e5f50eac6d49a0282e1b75399 Parents: 6a9a211 Author: David Neuman <david.neuma...@gmail.com> Authored: Wed Nov 30 10:20:38 2016 -0700 Committer: Dave Neuman <neu...@apache.org> Committed: Fri Dec 2 15:22:55 2016 -0700 ---------------------------------------------------------------------- traffic_ops/client/fixtures/types.go | 2 ++ traffic_ops/client/tests/type_test.go | 12 ++++++++++++ traffic_ops/client/type.go | 1 + 3 files changed, 15 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/21697fe9/traffic_ops/client/fixtures/types.go ---------------------------------------------------------------------- diff --git a/traffic_ops/client/fixtures/types.go b/traffic_ops/client/fixtures/types.go index 9f74c59..ef77346 100644 --- a/traffic_ops/client/fixtures/types.go +++ b/traffic_ops/client/fixtures/types.go @@ -22,8 +22,10 @@ func Types() *client.TypeResponse { return &client.TypeResponse{ Response: []client.Type{ client.Type{ + ID: 1, Name: "EDGE", Description: "edge cache", + UseInTable: "server", }, }, } http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/21697fe9/traffic_ops/client/tests/type_test.go ---------------------------------------------------------------------- diff --git a/traffic_ops/client/tests/type_test.go b/traffic_ops/client/tests/type_test.go index e4d8a43..a0edd41 100644 --- a/traffic_ops/client/tests/type_test.go +++ b/traffic_ops/client/tests/type_test.go @@ -45,6 +45,12 @@ func TestTypes(t *testing.T) { } for _, n := range types { + if n.ID != 1 { + testHelper.Error(t, "Should get back 1 for \"ID\", got %d", n.ID) + } else { + testHelper.Success(t, "Should get back 1 for \"ID\"") + } + if n.Name != "EDGE" { testHelper.Error(t, "Should get back \"EDGE\" for \"Name\", got %s", n.Name) } else { @@ -56,6 +62,12 @@ func TestTypes(t *testing.T) { } else { testHelper.Success(t, "Should get back \"edge cache\" for \"Description\"") } + + if n.UseInTable != "server" { + testHelper.Error(t, "Should get back \"server\" for \"UseInTable\", got %s", n.UseInTable) + } else { + testHelper.Success(t, "Should get back \"server\" for \"UseInTable\"") + } } } http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/21697fe9/traffic_ops/client/type.go ---------------------------------------------------------------------- diff --git a/traffic_ops/client/type.go b/traffic_ops/client/type.go index 088982b..3751c66 100644 --- a/traffic_ops/client/type.go +++ b/traffic_ops/client/type.go @@ -27,6 +27,7 @@ type TypeResponse struct { // Type contains information about a given Type in Traffic Ops. type Type struct { + ID int `json:"id"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` UseInTable string `json:"useInTable,omitempt"`