| 
 | 1 | +const importUtils = import("@apphosting/adapter-angular/dist/utils.js");  | 
 | 2 | +import assert from "assert";  | 
 | 3 | +import fs from "fs";  | 
 | 4 | +import { resolve } from "path";  | 
 | 5 | +import path from "path";  | 
 | 6 | +import { stringify as yamlStringify } from "yaml";  | 
 | 7 | +import os from "os";  | 
 | 8 | + | 
 | 9 | +const { metaFrameworkOutputBundleExists } = await importUtils;  | 
 | 10 | + | 
 | 11 | +function generateTmpDir(): string {  | 
 | 12 | +  return fs.mkdtempSync(path.join(os.tmpdir(), "test-files"));  | 
 | 13 | +}  | 
 | 14 | + | 
 | 15 | +describe("metaFrameworkOutputBundleExists", () => {  | 
 | 16 | +  let bundlePath: string;  | 
 | 17 | +  const originalCwd = process.cwd.bind(process);  | 
 | 18 | + | 
 | 19 | +  beforeEach(() => {  | 
 | 20 | +    const tmpDir = generateTmpDir();  | 
 | 21 | +    process.cwd = () => tmpDir;  | 
 | 22 | +    fs.mkdirSync(resolve(tmpDir, ".apphosting"));  | 
 | 23 | +    bundlePath = resolve(tmpDir, ".apphosting", "bundle.yaml");  | 
 | 24 | +  });  | 
 | 25 | + | 
 | 26 | +  afterEach(() => {  | 
 | 27 | +    process.cwd = originalCwd;  | 
 | 28 | +  });  | 
 | 29 | + | 
 | 30 | +  it("unrecogznied bundle", async () => {  | 
 | 31 | +    const content = "chicken: bok bok";  | 
 | 32 | +    fs.writeFileSync(bundlePath, yamlStringify(content));  | 
 | 33 | +    assert(!metaFrameworkOutputBundleExists());  | 
 | 34 | +  });  | 
 | 35 | + | 
 | 36 | +  it("no bundle exists", async () => {  | 
 | 37 | +    assert(!metaFrameworkOutputBundleExists());  | 
 | 38 | +  });  | 
 | 39 | + | 
 | 40 | +  it("meta-framework bundle exists", async () => {  | 
 | 41 | +    const outputBundle: OutputBundleConfig = {  | 
 | 42 | +      version: "v1",  | 
 | 43 | +      runConfig: {  | 
 | 44 | +        runCommand: `does not matter`,  | 
 | 45 | +      },  | 
 | 46 | +      metadata: {  | 
 | 47 | +        framework: "nitro",  | 
 | 48 | +      },  | 
 | 49 | +    };  | 
 | 50 | +    fs.writeFileSync(bundlePath, yamlStringify(outputBundle));  | 
 | 51 | +    assert(metaFrameworkOutputBundleExists());  | 
 | 52 | +  });  | 
 | 53 | + | 
 | 54 | +  it("angular bundle exists", async () => {  | 
 | 55 | +    const outputBundle: OutputBundleConfig = {  | 
 | 56 | +      version: "v1",  | 
 | 57 | + | 
 | 58 | +      runConfig: {  | 
 | 59 | +        runCommand: `does not matter`,  | 
 | 60 | +      },  | 
 | 61 | +      metadata: {  | 
 | 62 | +        framework: "angular",  | 
 | 63 | +      },  | 
 | 64 | +    };  | 
 | 65 | +    fs.writeFileSync(bundlePath, yamlStringify(outputBundle));  | 
 | 66 | +    assert(!metaFrameworkOutputBundleExists());  | 
 | 67 | +  });  | 
 | 68 | +});  | 
0 commit comments