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

fix: update testdata #1403

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 16 additions & 18 deletions test/metrics.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const openDigger = require('../src/metrics/index');
import * as fs from "fs";
const assert = require("assert");
import * as _ from "lodash";
import { existsSync, readFileSync } from 'fs';
import assert from "assert";
import _ from 'lodash';

function deepEqual(a: any, b: any): boolean {
return _.isEqual(a, b);
Expand All @@ -12,29 +12,27 @@ async function validateData(
subFileName: string,
dataKey: string
) {
const fileName = `../test/testdata1/${subFileName}/${dataKey}.json`;
const fileName = `test/testdata/${subFileName}/${dataKey}.json`;

if (fs.existsSync(fileName)) {
const jsonData = JSON.parse(fs.readFileSync(fileName).toString());
if (existsSync(fileName)) {
const jsonData = JSON.parse(readFileSync(fileName).toString());

const data1 = jsonData[dataKey];
const expectedData = jsonData[dataKey];
const queryResultData = await apiFn(jsonData["modifiedOption"]);

const data2 = await apiFn(jsonData["modifiedOption"]);
const expectedDataWithoutDetail = removeFields(expectedData);
const queryResultDataWithoutDetail = removeFields(queryResultData);

const data1WithoutDetail = removeFields(data1);

const data2WithoutDetail = removeFields(data2);

const equal = deepEqual(data1WithoutDetail, data2WithoutDetail);
const equal = deepEqual(expectedDataWithoutDetail, queryResultDataWithoutDetail);

if (!equal) {
console.log(jsonData["modifiedOption"]);
console.log(apiFn);
console.log("data1:", JSON.stringify(data1WithoutDetail));
console.log("data2:", JSON.stringify(data2WithoutDetail));
console.log("expected data: ", JSON.stringify(expectedDataWithoutDetail));
console.log("query result data: ", JSON.stringify(queryResultDataWithoutDetail));
}
assert(equal);
}
frank-zsy marked this conversation as resolved.
Show resolved Hide resolved
}
}

function removeFields(data: any) {
Expand Down Expand Up @@ -240,7 +238,7 @@ describe("Data tests", () => {
new_contributors_file_name
);
});
it("should test changeRequestsDeclined interface", async () => {
it("should test inactiveContributors interface", async () => {
const inactive_contributors_file_name =
`inactive_contributors_${order}_${limit}_${limitOption}_${groupBy}_${groupTimeRange}`.toLowerCase();
await validateData(
Expand All @@ -249,7 +247,7 @@ describe("Data tests", () => {
inactive_contributors_file_name
);
});
it("should test changeRequestsDeclined interface", async () => {
it("should test changeRequestsAcceptanceRatio interface", async () => {
const change_requests_acceptance_ratio_file_name =
`change_requests_acceptance_ratio_${order}_${limit}_${limitOption}_${groupBy}_${groupTimeRange}`.toLowerCase();
await validateData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,258 +14,62 @@
"groupTimeRange": "quarter",
"groupBy": null
},
"change_request_resolution_duration_desc_3_all_null_quarter": [
{
"id": "40736127",
"name": "google/cityhash",
"avg": [
null,
null,
null,
null,
null,
null,
null,
2326
],
"levels": [
[],
[],
[],
[],
[],
[],
[],
[
"0",
"0",
"0",
"1"
]
],
"quantile_0": [
null,
null,
null,
null,
null,
null,
null,
2326
],
"quantile_1": [
null,
null,
null,
null,
null,
null,
null,
2326
],
"quantile_2": [
null,
null,
null,
null,
null,
null,
null,
2326
],
"quantile_3": [
null,
null,
null,
null,
null,
null,
null,
2326
],
"quantile_4": [
null,
null,
null,
null,
null,
null,
null,
2326
]
},
{
"id": "38279227",
"name": "google/omaha",
"avg": [
null,
null,
null,
6,
2,
null,
2.33,
2022
],
"levels": [
[],
[],
[],
[
"0",
"1",
"0",
"0"
],
[
"1",
"0",
"0",
"0"
],
[],
[
"2",
"1",
"0",
"0"
],
[
"0",
"0",
"0",
"1"
]
],
"quantile_0": [
null,
null,
null,
6,
2,
null,
0,
2022
],
"quantile_1": [
null,
null,
null,
6,
2,
null,
0.5,
2022
],
"quantile_2": [
null,
null,
null,
6,
2,
null,
1,
2022
],
"quantile_3": [
null,
null,
null,
6,
2,
null,
3.5,
2022
],
"quantile_4": [
null,
null,
null,
6,
2,
null,
6,
2022
]
},
{
"id": "42134050",
"name": "google/appengine-jenkins",
"avg": [
null,
null,
null,
null,
null,
null,
null,
1596
],
"levels": [
[],
[],
[],
[],
[],
[],
[],
[
"0",
"0",
"0",
"1"
]
],
"quantile_0": [
null,
null,
null,
null,
null,
null,
null,
1596
],
"quantile_1": [
null,
null,
null,
null,
null,
null,
null,
1596
],
"quantile_2": [
null,
null,
null,
null,
null,
null,
null,
1596
],
"quantile_3": [
null,
null,
null,
null,
null,
null,
null,
1596
],
"quantile_4": [
null,
null,
null,
null,
null,
null,
null,
1596
]
}
]
"change_request_resolution_duration_desc_3_all_null_quarter": [{
"id": "40198544",
"name": "google/capirca",
"avg": [null, null, 0, 46, 0.5, 44.08, 12, 35],
"levels": [
[],
[],
["1", "0", "0", "0"],
["2", "2", "0", "2"],
["2", "0", "0", "0"],
["4", "2", "0", "7"],
["2", "1", "0", "1"],
["2", "0", "0", "2"]
],
"quantile_0": [null, null, 0, 0, 0, 0, 0, 0],
"quantile_1": [null, null, 0, 1, 0.25, 3, 0, 2.25],
"quantile_2": [null, null, 0, 4.5, 0.5, 17, 3.5, 33.5],
"quantile_3": [null, null, 0, 95.75, 0.75, 45, 15.5, 66.25],
"quantile_4": [null, null, 0, 141, 1, 186, 41, 73]
}, {
"id": "24993103",
"name": "google/woff2",
"avg": [50.5, 20.9, 32, 8.5, 1.6, null, 0, 35],
"levels": [
["2", "0", "0", "4"],
["4", "2", "1", "3"],
["1", "0", "0", "1"],
["0", "1", "1", "0"],
["4", "0", "1", "0"],
[],
["1", "0", "0", "0"],
["0", "0", "0", "1"]
],
"quantile_0": [0, 0, 2, 4, 0, null, 0, 35],
"quantile_1": [9.25, 1.5, 17, 6.25, 0, null, 0, 35],
"quantile_2": [41, 5, 32, 8.5, 0, null, 0, 35],
"quantile_3": [71.25, 15, 47, 10.75, 0, null, 0, 35],
"quantile_4": [141, 90, 62, 13, 8, null, 0, 35]
}, {
"id": "33881870",
"name": "google/protobuf-gradle-plugin",
"avg": [null, 3, 3.4, 16, 2.4, 20.5, 0.83, 28],
"levels": [
[],
["4", "2", "0", "0"],
["2", "3", "0", "0"],
["1", "0", "0", "1"],
["3", "2", "0", "0"],
["3", "2", "0", "1"],
["6", "0", "0", "0"],
["0", "0", "0", "1"]
],
"quantile_0": [null, 0, 1, 0, 0, 1, 0, 28],
"quantile_1": [null, 0.75, 2, 8, 0, 1, 0, 28],
"quantile_2": [null, 3, 4, 16, 1, 2.5, 0.5, 28],
"quantile_3": [null, 4.5, 4, 24, 4, 4.75, 1, 28],
"quantile_4": [null, 7, 6, 32, 7, 111, 3, 28]
}]
}
Loading