This is an automated email from the ASF dual-hosted git repository. dangogh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit a0e2ade26b9fa089c5ec2a26dfd3767e0e9715a9 Author: Dewayne Richardson <dewr...@apache.org> AuthorDate: Tue Feb 27 11:42:48 2018 -0700 updated to use TimeNoMod on the physlocation handler --- lib/go-tc/physlocations.go | 28 +++++++++++----------- .../parameter/parameters_test.go | 24 ++++++++----------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/go-tc/physlocations.go b/lib/go-tc/physlocations.go index 76d6c18..6d957ee 100644 --- a/lib/go-tc/physlocations.go +++ b/lib/go-tc/physlocations.go @@ -45,18 +45,18 @@ type PhysLocationNullable struct { // // NOTE: the db: struct tags are used for testing to map to their equivalent database column (if there is one) // - Address *string `json:"address" db:"address"` - City *string `json:"city" db:"city"` - Comments *string `json:"comments" db:"comments"` - Email *string `json:"email" db:"email"` - ID *int `json:"id" db:"id"` - LastUpdated TimeNoMod `json:"lastUpdated" db:"last_updated"` - Name *string `json:"name" db:"name"` - Phone *string `json:"phone" db:"phone"` - POC *string `json:"poc" db:"poc"` - RegionID *int `json:"regionId" db:"region"` - RegionName *string `json:"region" db:"region_name"` - ShortName *string `json:"shortName" db:"short_name"` - State *string `json:"state" db:"state"` - Zip *string `json:"zip" db:"zip"` + Address *string `json:"address" db:"address"` + City *string `json:"city" db:"city"` + Comments *string `json:"comments" db:"comments"` + Email *string `json:"email" db:"email"` + ID *int `json:"id" db:"id"` + LastUpdated *TimeNoMod `json:"lastUpdated" db:"last_updated"` + Name *string `json:"name" db:"name"` + Phone *string `json:"phone" db:"phone"` + POC *string `json:"poc" db:"poc"` + RegionID *int `json:"regionId" db:"region"` + RegionName *string `json:"region" db:"region_name"` + ShortName *string `json:"shortName" db:"short_name"` + State *string `json:"state" db:"state"` + Zip *string `json:"zip" db:"zip"` } diff --git a/traffic_ops/traffic_ops_golang/parameter/parameters_test.go b/traffic_ops/traffic_ops_golang/parameter/parameters_test.go index a5e20b0..6d78fe3 100644 --- a/traffic_ops/traffic_ops_golang/parameter/parameters_test.go +++ b/traffic_ops/traffic_ops_golang/parameter/parameters_test.go @@ -24,6 +24,7 @@ import ( "time" "github.com/apache/incubator-trafficcontrol/lib/go-tc" + "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/api" "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth" "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/test" "github.com/jmoiron/sqlx" @@ -70,8 +71,6 @@ func TestGetParameters(t *testing.T) { cols := test.ColsFromStructByTag("db", tc.Parameter{}) rows := sqlmock.NewRows(cols) - //TODO: drichardson - build helper to add these Rows from the struct values - // or by CSV if types get in the way for _, ts := range testParameters { rows = rows.AddRow( ts.ConfigFile, @@ -86,25 +85,22 @@ func TestGetParameters(t *testing.T) { mock.ExpectQuery("SELECT").WillReturnRows(rows) v := map[string]string{"dsId": "1"} - parameters, errs, errType := getParameters(v, db, auth.PrivLevelAdmin) + parameters, errs, _ := refType.Read(db, v, auth.CurrentUser{}) if len(errs) > 0 { - t.Errorf("getParameters expected: no errors, actual: %v with error type: %s", errs, errType.String()) + t.Errorf("parameter.Read expected: no errors, actual: %v", errs) } if len(parameters) != 2 { - t.Errorf("getParameters expected: len(parameters) == 1, actual: %v", len(parameters)) + t.Errorf("parameter.Read expected: len(parameters) == 2, actual: %v", len(parameters)) } } -type SortableParameters []tc.Parameter +func TestInterfaces(t *testing.T) { + var i interface{} + i = &TOParameter{} -func (s SortableParameters) Len() int { - return len(s) -} -func (s SortableParameters) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} -func (s SortableParameters) Less(i, j int) bool { - return s[i].Name < s[j].Name + if _, ok := i.(api.Reader); !ok { + t.Errorf("PhysLocation must be Reader") + } } -- To stop receiving notification emails like this one, please contact dang...@apache.org.