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 11:28:16 UTC

[GitHub] [trafficcontrol] dmohan001c opened a new pull request #5772: Adds TO client api tests for Coordinates automation

dmohan001c opened a new pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772


   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [ ] This PR fixes #REPLACE_ME OR is not related to any Issue <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - CDN in a Box
   - Traffic Ops
   - CI tests
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [ ] This PR includes tests OR I have explained why tests are unnecessary
   - [ ] This PR includes documentation OR I have explained why documentation is unnecessary
   - [ ] This PR includes an update to CHANGELOG.md OR such an update is not necessary
   - [ ] This PR includes any and all required license headers
   - [ ] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


-- 
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618125670



##########
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:
       updated the error response.

##########
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:
       added null checks




-- 
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618124539



##########
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:
       Fixed




-- 
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618128366



##########
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:
       added null checks

##########
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:
       Removed err in t.Errorf print statements.




-- 
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618128662



##########
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:
       added null checks
   




-- 
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618128568



##########
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:
       added null checks
   




-- 
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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618125358



##########
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:
       Fixed.




-- 
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



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

Posted by GitBox <gi...@apache.org>.
dmohan001c commented on a change in pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772#discussion_r618128230



##########
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:
       Removed err in t.Errorf print statements.




-- 
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



[GitHub] [trafficcontrol] ocket8888 merged pull request #5772: Adds TO client api tests for Coordinates automation

Posted by GitBox <gi...@apache.org>.
ocket8888 merged pull request #5772:
URL: https://github.com/apache/trafficcontrol/pull/5772


   


-- 
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