38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { rmSync } from "fs";
|
|
import { StackService } from "../../src/core/services/stack_service";
|
|
import { delay } from "../../src/core/helpers/delay";
|
|
import { assert, dirname__ } from "../test";
|
|
import { mockSimplePipeline } from "../model/mock_pipelines";
|
|
import { readDirRecursive } from "../../src/core/repository/fs";
|
|
|
|
abstract class IStackServiceTest {
|
|
abstract test(): Promise<boolean>;
|
|
}
|
|
|
|
class SimpleTestStackServiceTest extends StackService implements IStackServiceTest {
|
|
constructor() {
|
|
super(mockSimplePipeline, dirname__ + "/context/");
|
|
}
|
|
async test(): Promise<boolean> {
|
|
await this.call();
|
|
const testResult = readDirRecursive(this.path).equals(["1.txt", "test.txt"], true);
|
|
await delay(100);
|
|
rmSync(this.path + "example/", { recursive: true });
|
|
return testResult;
|
|
}
|
|
}
|
|
|
|
export class StackServiceTest {
|
|
dirName: string;
|
|
|
|
constructor(dirName: string) {
|
|
this.dirName = dirName;
|
|
}
|
|
public async test() {
|
|
const tests = [new SimpleTestStackServiceTest()];
|
|
for await (const el of tests) {
|
|
assert((await el.test()) === true, el.constructor.name);
|
|
await delay(3000);
|
|
}
|
|
}
|
|
}
|