refactor: build system

This commit is contained in:
2023-03-22 11:45:30 +01:00
parent 4df19e8c20
commit 8cb9285462
427 changed files with 3978 additions and 9810 deletions

View File

@@ -57,63 +57,73 @@ export class CopySpec {
async copy() {
type responses = Response<SCBulkAddResponse | SCBulkDoneResponse | SCBulkResponse | SCSearchResponse>;
sandbox.on(httpClient, 'request', async (request: RequestOptions): Promise<RecursivePartial<responses>> => {
if (request.url.toString() === 'http://foo.bar' + searchRoute.getUrlPath().toString()) {
const body = request.body as SCSearchRequest;
sandbox.on(
httpClient,
'request',
async (request: RequestOptions): Promise<RecursivePartial<responses>> => {
if (request.url.toString() === 'http://foo.bar' + searchRoute.getUrlPath().toString()) {
const body = request.body as SCSearchRequest;
let count = 0;
if (typeof body.size === 'number' && body.size > 0) {
count = 1;
let count = 0;
if (typeof body.size === 'number' && body.size > 0) {
count = 1;
}
return {
body: {
data: [
{
categories: ['main dish'],
name: 'foobar',
origin: {
indexed: moment().format(),
name: 'bar',
},
type: SCThingType.Dish,
uid: 'foo',
},
],
facets: [],
pagination: {
count: count,
offset: 0,
total: 1,
},
stats: {
time: 1,
},
},
statusCode: searchRoute.statusCodeSuccess,
};
} else if (request.url.toString() === 'http://localhost' + bulkRoute.getUrlPath().toString()) {
return {
body: {
state: 'in progress',
uid: 'foo',
},
statusCode: bulkRoute.statusCodeSuccess,
};
} else if (
request.url.toString() ===
'http://localhost' +
bulkAddRoute
.getUrlPath({
UID: 'foo',
})
.toString()
) {
return {
body: {},
statusCode: bulkAddRoute.statusCodeSuccess,
};
}
return {
body: {
data: [{
categories: [
'main dish',
],
name: 'foobar',
origin: {
indexed: moment().format(),
name: 'bar',
},
type: SCThingType.Dish,
uid: 'foo',
}],
facets: [],
pagination: {
count: count,
offset: 0,
total: 1,
},
stats: {
time: 1,
},
},
statusCode: searchRoute.statusCodeSuccess,
};
} else if (request.url.toString() === 'http://localhost' + bulkRoute.getUrlPath().toString()) {
return {
body: {
state: 'in progress',
uid: 'foo',
},
statusCode: bulkRoute.statusCodeSuccess,
};
} else if (request.url.toString() === 'http://localhost' + bulkAddRoute.getUrlPath({
UID: 'foo',
}).toString()) {
return {
body: {},
statusCode: bulkAddRoute.statusCodeSuccess,
statusCode: bulkDoneRoute.statusCodeSuccess,
};
}
return {
body: {},
statusCode: bulkDoneRoute.statusCodeSuccess,
};
});
},
);
await copy(httpClient, {
batchSize: 5,
@@ -129,62 +139,72 @@ export class CopySpec {
async copyShouldFail() {
type responses = Response<SCBulkAddResponse | SCBulkDoneResponse | SCBulkResponse | SCSearchResponse>;
sandbox.on(httpClient, 'request', async (request: RequestOptions): Promise<RecursivePartial<responses>> => {
if (request.url.toString() === 'http://foo.bar' + searchRoute.getUrlPath().toString()) {
const body = request.body as SCSearchRequest;
sandbox.on(
httpClient,
'request',
async (request: RequestOptions): Promise<RecursivePartial<responses>> => {
if (request.url.toString() === 'http://foo.bar' + searchRoute.getUrlPath().toString()) {
const body = request.body as SCSearchRequest;
if (typeof body.size === 'number' && body.size > 0) {
throw new ApiError({});
if (typeof body.size === 'number' && body.size > 0) {
throw new ApiError({});
}
return {
body: {
data: [
{
categories: ['main dish'],
name: 'foobar',
origin: {
indexed: moment().format(),
name: 'bar',
},
type: SCThingType.Dish,
uid: 'foo',
},
],
facets: [],
pagination: {
count: 0,
offset: 0,
total: 1,
},
stats: {
time: 1,
},
},
statusCode: searchRoute.statusCodeSuccess,
};
} else if (request.url.toString() === 'http://localhost' + bulkRoute.getUrlPath().toString()) {
return {
body: {
state: 'in progress',
uid: 'foo',
},
statusCode: bulkRoute.statusCodeSuccess,
};
} else if (
request.url.toString() ===
'http://localhost' +
bulkAddRoute
.getUrlPath({
UID: 'foo',
})
.toString()
) {
return {
body: {},
statusCode: bulkAddRoute.statusCodeSuccess,
};
}
return {
body: {
data: [{
categories: [
'main dish',
],
name: 'foobar',
origin: {
indexed: moment().format(),
name: 'bar',
},
type: SCThingType.Dish,
uid: 'foo',
}],
facets: [],
pagination: {
count: 0,
offset: 0,
total: 1,
},
stats: {
time: 1,
},
},
statusCode: searchRoute.statusCodeSuccess,
};
} else if (request.url.toString() === 'http://localhost' + bulkRoute.getUrlPath().toString()) {
return {
body: {
state: 'in progress',
uid: 'foo',
},
statusCode: bulkRoute.statusCodeSuccess,
};
} else if (request.url.toString() === 'http://localhost' + bulkAddRoute.getUrlPath({
UID: 'foo',
}).toString()) {
return {
body: {},
statusCode: bulkAddRoute.statusCodeSuccess,
statusCode: bulkDoneRoute.statusCodeSuccess,
};
}
return {
body: {},
statusCode: bulkDoneRoute.statusCodeSuccess,
};
});
},
);
return copy(httpClient, {
batchSize: 5,