Skip to content

Commit

Permalink
Changes in tests #81
Browse files Browse the repository at this point in the history
  • Loading branch information
johnantonn committed Dec 1, 2020
1 parent ca03f3d commit 2ed4e37
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 33 deletions.
4 changes: 2 additions & 2 deletions __test__/average.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test /average route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -31,7 +31,7 @@ describe("Test /average route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
Expand Down
4 changes: 2 additions & 2 deletions __test__/count.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test /count route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -31,7 +31,7 @@ describe("Test /count route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test(`count ${NUM_OF_DOCS} measurements from collection ’${eventCollection}’`, async () => {
const query = {
Expand Down
28 changes: 11 additions & 17 deletions __test__/eeris.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ describe("Test /eeris route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ${EERIS_EVENT_COLLECTION}`, async () => {
const payload = [];
for (let i = 1; i < NUM_OF_DOCS + 1; i += 1) {
payload.push({
data: {
a: i,
active: i,
b: i,
c: i.toString(),
},
Expand All @@ -39,14 +39,14 @@ describe("Test /eeris route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
masterKey: CENOTE_MASTER_KEY,
event_collection: EERIS_EVENT_COLLECTION,
};
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris`, { query });
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris/historical`, { query });
expect(response.statusCode).toBe(400);
expect(response.body.ok).toBe(false);
expect(response.body.results).toBe("TargetNotProvidedError");
Expand All @@ -58,7 +58,7 @@ describe("Test /eeris route", () => {
event_collection: "blabla",
target_property: "a",
};
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris`, { query });
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris/historical`, { query });
expect(response.statusCode).toBe(400);
expect(response.body.ok).toBe(false);
});
Expand All @@ -72,17 +72,15 @@ describe("Test /eeris route", () => {
const query = {
masterKey: CENOTE_MASTER_KEY,
event_collection: EERIS_EVENT_COLLECTION,
target_property: "a",
target_property: "active",
type: "week",
};
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris`, { query });
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris/historical`, { query });

expect(response.statusCode).toBe(200);
expect(response.body.ok).toBe(true);
expect(response.body.results.values.length).toBe(7);
expect(response.body.results.values[6]).toBe(avg);
expect(response.body.results.stats.max).toBe(NUM_OF_DOCS);
expect(response.body.results.stats.min).toBe(1);
expect(response.body.results.stats.avg).toBe(avg);
});

Expand All @@ -95,16 +93,14 @@ describe("Test /eeris route", () => {
const query = {
masterKey: CENOTE_MASTER_KEY,
event_collection: EERIS_EVENT_COLLECTION,
target_property: "a",
target_property: "active",
type: "month",
};
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris`, { query });
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris/historical`, { query });
expect(response.statusCode).toBe(200);
expect(response.body.ok).toBe(true);
expect(response.body.results.values.length).toBe(new Date().getDate());
expect(response.body.results.values[new Date().getDate() - 1]).toBe(avg);
expect(response.body.results.stats.max).toBe(NUM_OF_DOCS);
expect(response.body.results.stats.min).toBe(1);
expect(response.body.results.stats.avg).toBe(avg);
});

Expand All @@ -123,18 +119,16 @@ describe("Test /eeris route", () => {
const query = {
masterKey: CENOTE_MASTER_KEY,
event_collection: EERIS_EVENT_COLLECTION,
target_property: "a",
target_property: "active",
type: "day",
dt: dateString,
};
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris`, { query });
const response = await got.get(`/projects/${PROJECT_ID}/queries/eeris/historical`, { query });

expect(response.statusCode).toBe(200);
expect(response.body.ok).toBe(true);
expect(response.body.results.values.length).toBe(24);
expect(response.body.results.values[hours + offsetCI]).toBe(avg);
expect(response.body.results.stats.max).toBe(NUM_OF_DOCS);
expect(response.body.results.stats.min).toBe(1);
expect(response.body.results.stats.avg).toBe(avg);
});
});
4 changes: 2 additions & 2 deletions __test__/maximum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test /maximum route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -31,7 +31,7 @@ describe("Test /maximum route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
Expand Down
4 changes: 2 additions & 2 deletions __test__/median.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Test /median route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -37,7 +37,7 @@ describe("Test /median route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
Expand Down
4 changes: 2 additions & 2 deletions __test__/minimum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test /minimum route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -31,7 +31,7 @@ describe("Test /minimum route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
Expand Down
4 changes: 2 additions & 2 deletions __test__/percentile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test /percentile route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -31,7 +31,7 @@ describe("Test /percentile route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
Expand Down
4 changes: 2 additions & 2 deletions __test__/sum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test /sum route", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test(`add ${NUM_OF_DOCS} measurements to collection ’${eventCollection}’`, async () => {
const payload = [];
Expand All @@ -31,7 +31,7 @@ describe("Test /sum route", () => {
({ count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0]);
}
expect(count).toBe(NUM_OF_DOCS);
}, 500 * 1000);
}, 20 * 1000);

test("query without specifying target_property property fails", async () => {
const query = {
Expand Down
4 changes: 2 additions & 2 deletions __test__/write.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("Test write functionality", () => {
} else {
expect(response.statusCode).toBe(204);
}
}, 500 * 1000);
}, 20 * 1000);

test("500 new measurements should be written at most after 10 seconds.", async () => {
const payload = [];
Expand All @@ -29,7 +29,7 @@ describe("Test write functionality", () => {
await delay(10 * 1000);
const { count } = (await got.get(`/projects/${PROJECT_ID}/queries/count`, { query })).body.results[0];
expect(count).toBe(500);
}, 500 * 1000);
}, 20 * 1000);

test("Writing to event collection with special characters in its name fails", async () => {
const payload = [{ data: { a: 0, b: 0, c: (0).toString() } }];
Expand Down

0 comments on commit 2ed4e37

Please sign in to comment.