Skip to content

Commit

Permalink
Merge pull request #38 from djake/bug-empty-simulated-deleted-files
Browse files Browse the repository at this point in the history
Bugfix - Empty simulated deleted files
  • Loading branch information
vlad-ignatov authored Jan 18, 2021
2 parents aa59896 + 09541d3 commit 834c7f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ExportManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ class ExportManager
if (this.simulateDeletedPct && this.since) {
let cnt = Math.round(count/100 * this.simulateDeletedPct);

deletedArr.push({
cnt && deletedArr.push({
type: row.fhir_type,
count: cnt,
url: lib.buildUrlPath(
Expand Down
17 changes: 16 additions & 1 deletion tests/bulk_data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Client
* @param {object} [options.headers = {}]
* @param {boolean} [options.secure = false]
* @param {string} [options.fileError]
* @param {number} [options.del]
*/
async kickOff(options = {})
{
Expand All @@ -134,7 +135,8 @@ class Client
err : options.simulatedError || "",
extended: !!options.extended,
secure : !!options.secure,
fileError: options.fileError
fileError: options.fileError,
del: options.del
};

if (options.resourcesPerFile) {
Expand Down Expand Up @@ -1592,6 +1594,19 @@ describe("File Downloading", function() {
}
}
});

it("Retrieval of referenced files on an open endpoint with deletions", async () => {
const client = new Client();
await client.kickOff({ _type: "Device", _since: "2010-01-01T12:00:00Z", del: 10 });
const status = await client.checkStatus();

const deleted = status.body.deleted
assert(Array.isArray(deleted))

await Promise.all(
deleted.map(file => client.downloadFile(file.url))
)
});

it("Retrieval of referenced files on protected endpoint", async () => {
const { access_token } = await lib.authorize();
Expand Down

0 comments on commit 834c7f9

Please sign in to comment.