From 153c52651eb7320ba8d9223fa65c3660dd2e354d Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 9 Nov 2020 18:13:00 -0500 Subject: [PATCH] add test for first response no items, second response with items --- legacy/routes/paging.js | 13 +++++++++++++ package.json | 2 +- swagger/paging.json | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/legacy/routes/paging.js b/legacy/routes/paging.js index 7b586e7f..e34ba086 100644 --- a/legacy/routes/paging.js +++ b/legacy/routes/paging.js @@ -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"]++; @@ -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'; diff --git a/package.json b/package.json index 8e7bdd8e..528c7129 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/swagger/paging.json b/swagger/paging.json index df7b1bd2..d6c44432 100644 --- a/swagger/paging.json +++ b/swagger/paging.json @@ -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" },