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 2021/04/21 16:45:49 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #5772: Adds TO client api tests for Coordinates automation

ocket8888 commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r617707111



##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -147,6 +158,35 @@ func SortTestCoordinates(t *testing.T) {
 	}
 }
 
+func SortTestCoordinatesDesc(t *testing.T) {
+
+	respAsc, _, err1 := TOSession.GetCoordinates(nil, nil)
+	params := url.Values{}
+	params.Set("sortOrder", "desc")
+	respDesc, _, err2 := TOSession.GetCoordinates(params, nil)
+
+	if err1 != nil {
+		t.Errorf("Expected no error, but got error in Coordinates Ascending %v", err1)
+	}
+	if err2 != nil {
+		t.Errorf("Expected no error, but got error in Coordinates Descending %v", err2)
+	}
+
+	if len(respAsc) > 0 && len(respDesc) > 0 {
+		// reverse the descending-sorted response and compare it to the ascending-sorted one
+		for start, end := 0, len(respDesc)-1; start < end; start, end = start+1, end-1 {
+			respDesc[start], respDesc[end] = respDesc[end], respDesc[start]
+		}
+		if respDesc[0].Name != "" && respAsc[0].Name != "" {
+			if !reflect.DeepEqual(respDesc[0].Name, respAsc[0].Name) {
+				t.Errorf("Coordinates responses are not equal after reversal: %s - %s", *&respDesc[0].Name, *&respAsc[0].Name)

Review comment:
       nit, but you don't need `reflect.DeepEqual` to check string equality, and `*&` is a no-op

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)

Review comment:
       this will always print `Getting Coordinates by Invalid Name <nil>`, which I think is confusing because it appears to be complaining about an error that's `nil` when actually we expected an error and didn't get one.

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLatitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Latitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Latitude %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLogitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Longitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Longitude %v", err)

Review comment:
       same as above RE: error wording

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLatitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Latitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Latitude %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLogitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Longitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Longitude %v", err)
+	}
+}
+
+func UpdateTestCoordinatesByInvalidId(t *testing.T) {
+	firstCoord := testData.Coordinates[0]
+	resp, reqInf, err := TOSession.GetCoordinateByName(firstCoord.Name, nil)
+	if err != nil {
+		t.Errorf("cannot GET Coordinate by name: %v - %v", firstCoord.Name, err)
+	}
+	coord := resp[0]

Review comment:
       this will segfault if Traffic Ops returns an empty response, which can occur if the creation failed for this Coordinate or if there's simply something wrong with the GET handler

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLatitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Latitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Latitude %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLogitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]

Review comment:
       same as above RE: segfault

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLatitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Latitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Latitude %v", err)

Review comment:
       same as above RE: error wording

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLatitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]

Review comment:
       same as above RE: segfault

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]

Review comment:
       This will segfault if there are no Coordinates in the testing data.
   
   It's not so much a concern that someone will try to run the tests with modified data that's invalid, but the data is mutable after load, so other tests or even client methods that take slice references can put the data into a bad state. Which is actually something I ran into with the DSR tests where the client method was taking in references to DSRs and populating them with transient IDs for objects that would "stick" after the tests end.

##########
File path: traffic_ops/testing/api/v4/coordinates_test.go
##########
@@ -198,3 +238,174 @@ func DeleteTestCoordinates(t *testing.T) {
 		}
 	}
 }
+
+func GetTestCoordinatesByInvalidId(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByID(10000, nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid ID %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid ID shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestCoordiantesByInvalidName(t *testing.T) {
+	coordinatesResp, _, err := TOSession.GetCoordinateByName("abcd", nil)
+	if err != nil {
+		t.Errorf("Error!! Getting Coordinates by Invalid Name %v", err)
+	}
+	if len(coordinatesResp) >= 1 {
+		t.Errorf("Error!! Invalid Name shouldn't have any response %v Error %v", coordinatesResp, err)
+	}
+}
+
+func GetTestPaginationSupportCoordinates(t *testing.T) {
+
+	qparams := url.Values{}
+	qparams.Set("orderby", "id")
+	coordinates, _, err := TOSession.GetCoordinates(qparams, nil)
+	if err != nil {
+		t.Fatalf("cannot GET Coordinates: %v", err)
+	}
+
+	if len(coordinates) > 0 {
+		qparams = url.Values{}
+		qparams.Set("orderby", "id")
+		qparams.Set("limit", "1")
+		coordinatesWithLimit, _, err := TOSession.GetCoordinates(qparams, nil)
+		if err == nil {
+			if !reflect.DeepEqual(coordinates[:1], coordinatesWithLimit) {
+				t.Error("expected GET Coordinates with limit = 1 to return first result")
+			}
+		} else {
+			t.Error("Error in getting coordinates by limit")
+		}
+
+		if len(coordinates) > 1 {
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("offset", "1")
+			coordinatesWithOffset, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithOffset) {
+					t.Error("expected GET Coordinates with limit = 1, offset = 1 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and offset")
+			}
+
+			qparams = url.Values{}
+			qparams.Set("orderby", "id")
+			qparams.Set("limit", "1")
+			qparams.Set("page", "2")
+			coordinatesWithPage, _, err := TOSession.GetCoordinates(qparams, nil)
+			if err == nil {
+				if !reflect.DeepEqual(coordinates[1:2], coordinatesWithPage) {
+					t.Error("expected GET Coordinates with limit = 1, page = 2 to return second result")
+				}
+			} else {
+				t.Error("Error in getting coordinates by limit and page")
+			}
+		} else {
+			t.Errorf("only one Coordinates found, so offset functionality can't test")
+		}
+	} else {
+		t.Errorf("No Coordinates found to check pagination")
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "-2")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when limit is not bigger than -1")
+	} else if !strings.Contains(err.Error(), "must be bigger than -1") {
+		t.Errorf("expected GET Coordinates to return an error for limit is not bigger than -1, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("offset", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when offset is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for offset is not a positive integer, actual error: " + err.Error())
+	}
+
+	qparams = url.Values{}
+	qparams.Set("limit", "1")
+	qparams.Set("page", "0")
+	_, _, err = TOSession.GetCoordinates(qparams, nil)
+	if err == nil {
+		t.Error("expected GET Coordinates to return an error when page is not a positive integer")
+	} else if !strings.Contains(err.Error(), "must be a positive integer") {
+		t.Errorf("expected GET Coordinates to return an error for page is not a positive integer, actual error: " + err.Error())
+	}
+}
+
+func CreateTestCoordinatesWithInvalidName(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Name = ""
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Name %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLatitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Latitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Latitude %v", err)
+	}
+}
+
+func CreateTestCoordinatesWithInvalidLogitude(t *testing.T) {
+	firstCoordinates := testData.Coordinates[0]
+	firstCoordinates.Longitude = 20000
+	_, reqInf, err := TOSession.CreateCoordinate(firstCoordinates)
+	if reqInf.StatusCode != http.StatusBadRequest {
+		t.Fatalf("Expected 400 status code, got %v", reqInf.StatusCode)
+	}
+	if err == nil {
+		t.Errorf("Getting Coordinates by Invalid Longitude %v", err)
+	}
+}
+
+func UpdateTestCoordinatesByInvalidId(t *testing.T) {
+	firstCoord := testData.Coordinates[0]

Review comment:
       same as above RE: segfault




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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