Skip to content

Commit

Permalink
Update tests for search and observe
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAstafyev committed Dec 6, 2024
1 parent 30e2bc1 commit 68d34ce
Show file tree
Hide file tree
Showing 14 changed files with 1,825 additions and 1,786 deletions.
5 changes: 3 additions & 2 deletions application/apps/rustcore/ts-bindings/spec/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
},
"protocol": {
"regular": {
"execute_only": [],
"execute_only": [2,3],
"list": {
"1": "Test 1. CallbackEvent",
"2": "Test 2. Check all messages"
"2": "Test 2. Check all messages",
"3": "Test 3. Comparing JSON vs Protobuf"
},
"files": {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ describe('Exporting', function () {
let controlSum = 0;
const ranges = [
{
from: 50,
to: 100,
start: 50,
end: 100,
},
{
from: 200,
to: 300,
start: 200,
end: 300,
},
];
const tmpobj = createSampleFile(1000, logger, (i: number) => {
ranges.forEach((r) => {
if (i >= r.from && i <= r.to) {
if (i >= r.start && i <= r.end) {
controlSum += i;
}
});
Expand Down Expand Up @@ -109,23 +109,23 @@ describe('Exporting', function () {
return runners.withSession(config.regular, 2, async (logger, done, comps) => {
const ranges = [
{
from: 50,
to: 90,
start: 50,
end: 90,
},
{
from: 101,
to: 150,
start: 101,
end: 150,
},
];
let controlSum = 0;
const tmpobj_a = createSampleFile(100, logger, (i: number) => {
if (i >= ranges[0].from && i <= ranges[0].to) {
if (i >= ranges[0].start && i <= ranges[0].end) {
controlSum += i;
}
return `____${i}____\n`;
});
const tmpobj_b = createSampleFile(100, logger, (i: number) => {
if (i >= ranges[1].from - 100 && i <= ranges[1].to - 100) {
if (i >= ranges[1].start - 100 && i <= ranges[1].end - 100) {
controlSum += i * 1000;
}
return `____${i * 1000}____\n`;
Expand Down Expand Up @@ -234,15 +234,11 @@ describe('Exporting', function () {
.grab(range.from, range.to)
.then((grabbed: IGrabbedElement[]) => {
comps.stream
.export(
output,
fromIndexes(grabbed.map((el) => el.position)),
{
columns: [],
spliter: undefined,
delimiter: undefined,
},
)
.export(output, fromIndexes(grabbed.map((el) => el.pos)), {
columns: [],
spliter: undefined,
delimiter: undefined,
})
.then((_done) => {
fs.promises
.readFile(output, { encoding: 'utf-8' })
Expand Down Expand Up @@ -336,7 +332,7 @@ describe('Exporting', function () {
.then((grabbed) => {
const output = path.resolve(os.tmpdir(), `${v4()}.logs`);
comps.stream
.export(output, [{ from: 0, to: 8 }], {
.export(output, [{ start: 0, end: 8 }], {
columns: [],
spliter: undefined,
delimiter: undefined,
Expand All @@ -354,7 +350,7 @@ describe('Exporting', function () {
comps.session,
done,
new Error(
`Rows are dismatch. Stream position ${grabbed[i].position}.`,
`Rows are dismatch. Stream position ${grabbed[i].pos}.`,
),
);
}
Expand Down Expand Up @@ -432,7 +428,7 @@ describe('Exporting', function () {
.then((grabbed) => {
const output = path.resolve(os.tmpdir(), `${v4()}.dlt`);
comps.stream
.exportRaw(output, [{ from: 0, to: 8 }])
.exportRaw(output, [{ start: 0, end: 8 }])
.then(async () => {
comps.session
.destroy()
Expand Down Expand Up @@ -476,7 +472,7 @@ describe('Exporting', function () {
session,
done,
new Error(
`Rows are dismatch. Stream position ${grabbed[i].position}.`,
`Rows are dismatch. Stream position ${grabbed[i].pos}.`,
),
);
}
Expand Down Expand Up @@ -569,7 +565,7 @@ describe('Exporting', function () {
expect(grabbed[10].source_id).toEqual(1);
const output = path.resolve(os.tmpdir(), `${v4()}.logs`);
comps.stream
.export(output, [{ from: 0, to: 14 }], {
.export(output, [{ start: 0, end: 14 }], {
columns: [],
spliter: undefined,
delimiter: undefined,
Expand All @@ -587,7 +583,7 @@ describe('Exporting', function () {
comps.session,
done,
new Error(
`Rows are dismatch. Stream position ${grabbed[i].position}.`,
`Rows are dismatch. Stream position ${grabbed[i].pos}.`,
),
);
}
Expand Down Expand Up @@ -668,7 +664,7 @@ describe('Exporting', function () {
expect(grabbed[10].source_id).toEqual(1);
const output = path.resolve(os.tmpdir(), `${v4()}.logs`);
comps.stream
.exportRaw(output, [{ from: 0, to: 14 }])
.exportRaw(output, [{ start: 0, end: 14 }])
.then(() => {
comps.session
.destroy()
Expand Down Expand Up @@ -719,7 +715,7 @@ describe('Exporting', function () {
session,
done,
new Error(
`Rows are dismatch. Stream position ${grabbed[i].position}.`,
`Rows are dismatch. Stream position ${grabbed[i].pos}.`,
),
);
}
Expand Down Expand Up @@ -806,26 +802,26 @@ describe('Exporting', function () {
}
const ranges = [
{
from: 0,
to: 5,
start: 0,
end: 5,
},
{
from: 9,
to: 14,
start: 9,
end: 14,
},
];
gotten = true;
Promise.all(ranges.map((r) => comps.stream.grab(r.from, r.to - r.from)))
Promise.all(ranges.map((r) => comps.stream.grab(r.start, r.end - r.start)))
.then((results) => {
let grabbed: IGrabbedElement[] = [];
results.forEach((g) => (grabbed = grabbed.concat(g)));
grabbed.sort((a, b) => (a.position > b.position ? 1 : -1));
grabbed.sort((a, b) => (a.pos > b.pos ? 1 : -1));
const output = path.resolve(os.tmpdir(), `${v4()}.logs`);
comps.stream
.exportRaw(
output,
ranges.map((r) => {
return { from: r.from, to: r.to - 1 };
return { start: r.start, end: r.end - 1 };
}),
)
.then(() => {
Expand Down Expand Up @@ -870,7 +866,7 @@ describe('Exporting', function () {
session,
done,
new Error(
`Rows are dismatch. Stream position ${grabbed[i].position}.`,
`Rows are dismatch. Stream position ${grabbed[i].pos}.`,
),
);
}
Expand Down Expand Up @@ -960,7 +956,7 @@ describe('Exporting', function () {
.then((grabbed) => {
const output = path.resolve(os.tmpdir(), `${v4()}.txt`);
comps.stream
.export(output, [{ from: 0, to: 8 }], {
.export(output, [{ start: 0, end: 8 }], {
columns: [0, 1],
spliter: '\u0004',
delimiter: ';',
Expand Down Expand Up @@ -1053,7 +1049,7 @@ describe('Exporting', function () {
.then((grabbed) => {
const output = path.resolve(os.tmpdir(), `${v4()}.txt`);
comps.stream
.export(output, [{ from: 0, to: 8 }], {
.export(output, [{ start: 0, end: 8 }], {
columns: [9, 10],
spliter: '\u0004',
delimiter: ';',
Expand Down Expand Up @@ -1145,7 +1141,7 @@ describe('Exporting', function () {
.then((grabbed) => {
const output = path.resolve(os.tmpdir(), `${v4()}.txt`);
comps.stream
.export(output, [{ from: 0, to: 8 }], {
.export(output, [{ start: 0, end: 8 }], {
columns: [10],
spliter: '\u0004',
delimiter: ';',
Expand Down Expand Up @@ -1279,7 +1275,7 @@ describe('Exporting', function () {
cases.map((usecase) => {
const output = usecase.output;
return comps.stream
.export(output, [{ from: 0, to: 8 }], usecase.options)
.export(output, [{ start: 0, end: 8 }], usecase.options)
.then(async () => {
fs.promises
.readFile(output, { encoding: 'utf-8' })
Expand Down
Loading

0 comments on commit 68d34ce

Please sign in to comment.