UNPKG

singularci

Version:

SingularCI is a DSL transpiler used to generate CI/CD configuration files for existing CI platforms

47 lines 2.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const typedi_1 = __importDefault(require("typedi")); const Pipeline_1 = __importDefault(require("../../../src/SemanticModel/Pipeline")); const BuildDockerImage_1 = require("../../../src/SemanticModel/Tasks/BuildDockerImage"); const Trigger_1 = require("../../../src/SemanticModel/Trigger"); const GitHubModule_1 = require("../../../src/Targets/GitHubModule"); const GitLabModule_1 = require("../../../src/Targets/GitLabModule"); let parser; beforeAll(() => { typedi_1.default.import([ GitHubModule_1.GitHubConfigGenerator, GitLabModule_1.GitLabConfigGenerator, Pipeline_1.default, BuildDockerImage_1.BuildDockerImageFactory, Trigger_1.TriggerFactory ]); typedi_1.default.set('dslparser.inputFileName', './test/Parser/testfile.yml'); parser = typedi_1.default.get('dslparser'); }); test('When the generateConfig method has been run, a workflow file should be generated', () => { if (fs_1.default.existsSync(path_1.default.join(process.cwd(), ".github"))) { fs_1.default.rmSync(path_1.default.join(process.cwd(), ".github"), { recursive: true }); } expect(fs_1.default.existsSync(path_1.default.join(process.cwd(), ".github"))).toBe(false); const githubModule = new GitHubModule_1.GitHubConfigGenerator(parser); githubModule.generateConfig(); expect(fs_1.default.existsSync(path_1.default.join(process.cwd(), ".github/workflows/workflow.yml"))).toBe(true); expect(fs_1.default.readFileSync(path_1.default.join(process.cwd(), ".github/workflows/workflow.yml"), 'utf8').length).toBeGreaterThan(50); }); afterAll(() => { setTimeout(() => { if (fs_1.default.existsSync(path_1.default.join(process.cwd(), ".singularci-copy.yml"))) { fs_1.default.rmSync(path_1.default.join(process.cwd(), ".singularci-copy.yml")); } if (fs_1.default.existsSync(path_1.default.join(process.cwd(), ".github"))) { fs_1.default.rmSync(path_1.default.join(process.cwd(), ".github"), { recursive: true }); } }, 100); }); //# sourceMappingURL=index.test.js.map