Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Convert 'nil' bookmark string from couchdb to an actual null value (#266
Browse files Browse the repository at this point in the history
)

Signed-off-by: Eamonn Mansour <[email protected]>
  • Loading branch information
eamansour authored Aug 22, 2024
1 parent 978f791 commit 0b9a19e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ private RasRunResultPage getRunsPageFromCouchdb(HttpPost httpPost, Find query) t
}
}

// CouchDB sometimes returns a 'nil' string as a bookmark to indicate no bookmark,
// so turn it into an actual null value
if (found.bookmark != null && found.bookmark.equals("nil")) {
found.bookmark = null;
}

runsPage = new RasRunResultPage(runs, found.bookmark);
} catch (CouchdbRasException e) {
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,34 @@ public void testGetRunsPageByQueuedFromWithSortAndPageTokenReturnsRunsOk() throw
assertThat(runs.get(0).getTestStructure().getRunName()).isEqualTo(mockRun1.getRunName());
assertThat(runs.get(1).getTestStructure().getRunName()).isEqualTo(mockRun2.getRunName());
}

@Test
public void testGetRunsPageWithNilBookmarkReturnsPageWithNoNextCursor() throws Exception {
// Given...
TestStructureCouchdb mockRun1 = createRunTestStructure("run1");

Instant queuedFromTime = Instant.EPOCH;
RasSearchCriteriaQueuedFrom queuedFrom = new RasSearchCriteriaQueuedFrom(queuedFromTime);

FoundRuns findRunsResponse = new FoundRuns();
findRunsResponse.docs = List.of(mockRun1);
findRunsResponse.bookmark = "nil";

String expectedUri = "http://my.uri/galasa_run/_find";
List<HttpInteraction> interactions = List.of(
new PostCouchdbFindRunsInteraction(expectedUri, findRunsResponse, "queued", "$gte", queuedFromTime.toString())
);

MockLogFactory mockLogFactory = new MockLogFactory();
CouchdbRasStore mockRasStore = fixtures.createCouchdbRasStore(interactions, mockLogFactory);
CouchdbDirectoryService directoryService = new CouchdbDirectoryService(mockRasStore, mockLogFactory, new HttpRequestFactoryImpl());

int maxResults = 100;

// When...
RasRunResultPage runsPage = directoryService.getRunsPage(maxResults, null, null, queuedFrom);

// Then...
assertThat(runsPage.getNextCursor()).isNull();
}
}

0 comments on commit 0b9a19e

Please sign in to comment.