You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/03/12 22:54:27 UTC

[GitHub] dangogh closed pull request #1982: moved /hwinfo into its own package

dangogh closed pull request #1982: moved /hwinfo into its own package
URL: https://github.com/apache/incubator-trafficcontrol/pull/1982
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_ops/traffic_ops_golang/hwinfo.go b/traffic_ops/traffic_ops_golang/hwinfo/hwinfo.go
similarity index 98%
rename from traffic_ops/traffic_ops_golang/hwinfo.go
rename to traffic_ops/traffic_ops_golang/hwinfo/hwinfo.go
index 2502dbf30..466c75f7b 100644
--- a/traffic_ops/traffic_ops_golang/hwinfo.go
+++ b/traffic_ops/traffic_ops_golang/hwinfo/hwinfo.go
@@ -1,4 +1,4 @@
-package main
+package hwinfo
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -31,7 +31,7 @@ import (
 	"github.com/jmoiron/sqlx"
 )
 
-func hwInfoHandler(db *sqlx.DB) http.HandlerFunc {
+func HWInfoHandler(db *sqlx.DB) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		handleErrs := tc.GetHandleErrorsFunc(w, r)
 
diff --git a/traffic_ops/traffic_ops_golang/hwinfo_test.go b/traffic_ops/traffic_ops_golang/hwinfo/hwinfo_test.go
similarity index 87%
rename from traffic_ops/traffic_ops_golang/hwinfo_test.go
rename to traffic_ops/traffic_ops_golang/hwinfo/hwinfo_test.go
index 415f8de01..10f7be47c 100644
--- a/traffic_ops/traffic_ops_golang/hwinfo_test.go
+++ b/traffic_ops/traffic_ops_golang/hwinfo/hwinfo_test.go
@@ -1,4 +1,4 @@
-package main
+package hwinfo
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,8 +20,6 @@ package main
  */
 
 import (
-	"encoding/json"
-	"fmt"
 	"testing"
 	"time"
 
@@ -68,8 +66,6 @@ func TestGetHWInfo(t *testing.T) {
 	cols := test.ColsFromStructByTag("db", tc.HWInfo{})
 	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 testHWInfo {
 		rows = rows.AddRow(
 			ts.Description,
@@ -93,17 +89,6 @@ func TestGetHWInfo(t *testing.T) {
 	}
 }
 
-func TestJSON(t *testing.T) {
-	testHWInfo := getTestHWInfo()
-	txt, err := json.Marshal(testHWInfo)
-	if *debugLogging {
-		fmt.Printf("%v, %s\n", err, txt)
-	}
-	if err != nil {
-		t.Errorf("Json.Marshal failed: %s\n", err)
-	}
-}
-
 type SortableHWInfo []tc.HWInfo
 
 func (s SortableHWInfo) Len() int {
diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go
index 80e557f20..ff59cc351 100644
--- a/traffic_ops/traffic_ops_golang/routes.go
+++ b/traffic_ops/traffic_ops_golang/routes.go
@@ -35,6 +35,7 @@ import (
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/cdn"
 	dsrequest "github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/deliveryservice/request"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/division"
+	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/hwinfo"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/parameter"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/physlocation"
 	"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/ping"
@@ -141,8 +142,8 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
 		{1.3, http.MethodPost, `divisions/?$`, api.CreateHandler(division.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
 		{1.3, http.MethodDelete, `divisions/{id}$`, api.DeleteHandler(division.GetRefType(), d.DB), auth.PrivLevelOperations, Authenticated, nil},
 
-		//HwInfo
-		{1.2, http.MethodGet, `hwinfo-wip/?(\.json)?$`, hwInfoHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
+		//HWInfo
+		{1.2, http.MethodGet, `hwinfo-wip/?(\.json)?$`, hwinfo.HWInfoHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil},
 
 		//Regions
 		{1.3, http.MethodGet, `regions/?(\.json)?$`, api.ReadHandler(region.GetRefType(), d.DB), auth.PrivLevelReadOnly, Authenticated, nil},


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services