zrhoffman commented on code in PR #7132:
URL: https://github.com/apache/trafficcontrol/pull/7132#discussion_r995005089
##########
traffic_ops/testing/api/v4/cachegroups_test.go:
##########
@@ -65,184 +67,173 @@ func TestCacheGroups(t *testing.T) {
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusNotModified)),
},
"OK when VALID request": {
- ClientSession: TOSession, Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+ ClientSession: TOSession,
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
},
"OK when VALID NAME parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"name":
{"parentCachegroup"}}},
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"name":
{"parentCachegroup"}}},
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(1),
ValidateExpectedField("Name",
"parentCachegroup")),
},
"OK when VALID SHORTNAME parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"shortName": {"pg2"}}},
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"shortName": {"pg2"}}},
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(1),
ValidateExpectedField("ShortName", "pg2")),
},
"OK when VALID TOPOLOGY parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"topology":
{"mso-topology"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"topology":
{"mso-topology"}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
},
"OK when VALID TYPE parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"type": {"ORG_LOC"}}},
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"type":
{strconv.Itoa(GetTypeId(t, "ORG_LOC"))}}},
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseLengthGreaterOrEqual(1),
ValidateExpectedField("TypeName", "ORG_LOC")),
},
"EMPTY RESPONSE when INVALID ID parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"id": {"10000"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(0)),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"id": {"10000"}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(0)),
},
"EMPTY RESPONSE when INVALID TYPE parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"type": {"10000"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(0)),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"type": {"10000"}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
utils.ResponseHasLength(0)),
},
"FIRST RESULT when LIMIT=1": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"orderby": {"id"}, "limit":
{"1"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
ValidatePagination("limit")),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"orderby": {"id"}, "limit":
{"1"}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
ValidatePagination("limit")),
},
"SECOND RESULT when LIMIT=1 OFFSET=1": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"orderby": {"id"}, "limit":
{"1"}, "offset": {"1"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
ValidatePagination("offset")),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"orderby": {"id"}, "limit":
{"1"}, "offset": {"1"}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
ValidatePagination("offset")),
},
"SECOND RESULT when LIMIT=1 PAGE=2": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"orderby": {"id"}, "limit":
{"1"}, "page": {"2"}}},
- Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
ValidatePagination("page")),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"orderby": {"id"}, "limit":
{"1"}, "page": {"2"}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK),
ValidatePagination("page")),
},
"BAD REQUEST when INVALID LIMIT parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"limit": {"-2"}}},
- Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"limit": {"-2"}}},
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
},
"BAD REQUEST when INVALID OFFSET parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"limit": {"1"}, "offset":
{"0"}}},
- Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"limit": {"1"}, "offset":
{"0"}}},
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
},
"BAD REQUEST when INVALID PAGE parameter": {
- ClientSession: TOSession, RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"limit": {"1"}, "page":
{"0"}}},
- Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{QueryParameters: url.Values{"limit": {"1"}, "page":
{"0"}}},
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusBadRequest)),
},
"UNAUTHORIZED when NOT LOGGED IN": {
- ClientSession: NoAuthTOSession,
Expectations: utils.CkRequest(utils.HasError(),
utils.HasStatus(http.StatusUnauthorized)),
+ ClientSession: NoAuthTOSession,
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusUnauthorized)),
+ },
+ "OK when CHANGES made": {
+ ClientSession: TOSession,
+ RequestOpts:
client.RequestOptions{Header: http.Header{rfc.IfModifiedSince:
{currentTimeRFC}}},
+ Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
},
},
"POST": {
"UNAUTHORIZED when NOT LOGGED IN": {
- ClientSession: NoAuthTOSession,
Expectations: utils.CkRequest(utils.HasError(),
utils.HasStatus(http.StatusUnauthorized)),
+ ClientSession: NoAuthTOSession,
+ Expectations:
utils.CkRequest(utils.HasError(), utils.HasStatus(http.StatusUnauthorized)),
},
},
"PUT": {
"OK when VALID request": {
EndpointId: GetCacheGroupId(t,
"cachegroup1"), ClientSession: TOSession,
- RequestBody: map[string]interface{}{
- "latitude": 17.5,
- "longitude": 17.5,
- "name":
"cachegroup1",
- "shortName":
"newShortName",
- "localizationMethods":
[]string{"CZ"},
- "fallbacks":
[]string{"fallback1"},
- "typeName":
"EDGE_LOC",
- "typeId": -1,
+ RequestBody: tc.CacheGroupNullable{
+ Latitude:
util.Ptr(17.5),
+ Longitude:
util.Ptr(17.5),
+ Name:
util.Ptr("cachegroup1"),
+ ShortName:
util.Ptr("newShortName"),
+ LocalizationMethods:
util.Ptr([]tc.LocalizationMethod{tc.LocalizationMethodCZ}),
+ Fallbacks:
util.Ptr([]string{"fallback1"}),
+ Type:
util.Ptr("EDGE_LOC"),
+ TypeID:
util.Ptr(GetTypeId(t, "EDGE_LOC")),
},
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
},
"OK when updating CG with null Lat/Long": {
EndpointId: GetCacheGroupId(t,
"nullLatLongCG"), ClientSession: TOSession,
- RequestBody: map[string]interface{}{
- "name": "nullLatLongCG",
- "shortName": "null-ll",
- "typeName": "EDGE_LOC",
- "fallbacks":
[]string{"fallback1"},
- "typeId": -1,
+ RequestBody: tc.CacheGroupNullable{
+ Name:
util.Ptr("nullLatLongCG"),
+ ShortName: util.Ptr("null-ll"),
+ Type: util.Ptr("EDGE_LOC"),
+ Fallbacks:
util.Ptr([]string{"fallback1"}),
+ TypeID:
util.Ptr(GetTypeId(t, "EDGE_LOC")),
},
Expectations:
utils.CkRequest(utils.NoError(), utils.HasStatus(http.StatusOK)),
},
"BAD REQUEST when updating TYPE of CG in
TOPOLOGY": {
EndpointId: GetCacheGroupId(t,
"topology-edge-cg-01"), ClientSession: TOSession,
- RequestBody: map[string]interface{}{
- "id": -1,
- "latitude": 0,
- "longitude": 0,
- "name":
"topology-edge-cg-01",
- "shortName": "te1",
- "typeName": "MID_LOC",
- "typeId": -1,
+ RequestBody: tc.CacheGroupNullable{
+ Latitude: util.Ptr(0.0),
+ Longitude: util.Ptr(0.0),
+ Name:
util.Ptr("topology-edge-cg-01"),
+ ShortName: util.Ptr("te1"),
+ Type: util.Ptr("MID_LOC"),
+ TypeID:
util.Ptr(GetTypeId(t, "MIC_LOC")),
Review Comment:
```go
--- FAIL: TestCacheGroups (4.21s)
cachegroups_test.go:328: Not equal. Expected: 1 Actual: 0 Messages:
Expected response object length 1, but got 0
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]