Skip to content

Commit

Permalink
fix: update testdata (#1403)
Browse files Browse the repository at this point in the history
* update testdata

* modify the test script

* add the log for file not found
  • Loading branch information
Zzzzzhuzhiwei authored Oct 11, 2023
1 parent 304f9f3 commit ccc5381
Show file tree
Hide file tree
Showing 18 changed files with 7,127 additions and 2,484 deletions.
35 changes: 18 additions & 17 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,28 +12,29 @@ 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);
}
else {
console.log(`File ${fileName} not found, because the option is not supported.`);
}
}

Expand Down Expand Up @@ -240,7 +241,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 +250,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

0 comments on commit ccc5381

Please sign in to comment.