Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for first page no items, second page with items #235

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions legacy/routes/paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var paging = function(coverage) {
coverage['PagingCustomUrlPartialNextLink'] = 0;
coverage["PagingCustomUrlPartialOperationNextLink"] = 0;
coverage["PagingReturnModelWithXMSClientName"] = 0;
coverage["PagingFirstResponseEmpty"] = 0;

router.get('/noitemname', function(req, res, next) {
coverage["PagingNoItemName"]++;
Expand Down Expand Up @@ -206,6 +207,18 @@ var paging = function(coverage) {
res.status(200).json({ "values" : [ {"properties":{"id": 1, "name": "Product" }}]});
});

router.get('/firstResponseEmpty/:pagenumber', function(req, res, next) {
if (req.params.pagenumber == 1) {
res.status(200).json({ "values" : [], "nextLink":"/paging/firstResponseEmpty/2"});
} else if(req.params.pagenumber == 2) {
coverage["PagingFirstResponseEmpty"]++;
res.status(200).json({ "value" : [ {"properties":{"id": 1, "name": "Product" }}]});
} else {
res.status(400).end("Incorrect page number " + req.params.pagenumber + ". Needs to be either 1 for the initial call, or 2 for the final call");
}
});


/*** PAGEABLE LROs ***/
router.post('/multiple/lro', function (req, res, next) {
var pollingUri = 'http://localhost:' + utils.getPort() + '/paging/multiple/lro/200';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/autorest.testserver",
"version": "2.10.62",
"version": "2.10.63",
"main": "./legacy/startup/www.js",
"bin": {
"start-autorest-express": "./.scripts/start-autorest-express.js",
Expand Down
18 changes: 18 additions & 0 deletions swagger/paging.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@
}
}
},
"/paging/firstResponseEmpty/1": {
"get": {
"x-ms-pageable": { "nextLinkName": "nextLink" },
"operationId": "Paging_firstResponseEmpty",
"description": "A paging operation whose first response's items list is empty, but still returns a next link. Second (and final) call, will give you an items list of 1.",
"responses": {
"200": {
"description": "First call returns an empty items list, second (and final) call returns an items list of length 1.",
"schema": {
"$ref": "#/definitions/ProductResultValue"
}
},
"default": {
"description": "Unexpected error"
}
}
}
},
"/paging/multiple": {
"get": {
"x-ms-pageable": { "nextLinkName": "nextLink", "itemName": "values" },
Expand Down