|
| 1 | +import { localPathFileserver } from "../local-path"; |
| 2 | +import { mkdtemp, rm } from "node:fs/promises"; |
| 3 | +import { tmpdir } from "node:os"; |
| 4 | +import { join } from "path"; |
| 5 | +import { fsClient } from "@cocalc/conat/files/fs"; |
| 6 | + |
| 7 | +let tempDir; |
| 8 | +beforeAll(async () => { |
| 9 | + tempDir = await mkdtemp(join(tmpdir(), "cocalc-local-path")); |
| 10 | +}); |
| 11 | + |
1 | 12 | describe("use the simple fileserver", () => {
|
2 |
| - it("does nothing", async () => {}); |
| 13 | + let service; |
| 14 | + it("creates the simple fileserver service", async () => { |
| 15 | + service = await localPathFileserver({ service: "fs", path: tempDir }); |
| 16 | + }); |
| 17 | + |
| 18 | + const project_id = "6b851643-360e-435e-b87e-f9a6ab64a8b1"; |
| 19 | + let fs; |
| 20 | + it("create a client", () => { |
| 21 | + fs = fsClient({ subject: `fs.project-${project_id}` }); |
| 22 | + }); |
| 23 | + |
| 24 | + it("checks appendFile works", async () => { |
| 25 | + await fs.appendFile("a", "foo"); |
| 26 | + expect(await fs.readFile("a", "utf8")).toEqual("foo"); |
| 27 | + }); |
| 28 | + |
| 29 | + it("checks chmod works", async () => { |
| 30 | + await fs.writeFile("b", "hi"); |
| 31 | + await fs.chmod("b", 0o755); |
| 32 | + const s = await fs.stat("b"); |
| 33 | + expect(s.mode.toString(8)).toBe("100755"); |
| 34 | + }); |
| 35 | + |
| 36 | + it("closes the service", () => { |
| 37 | + service.close(); |
| 38 | + }); |
| 39 | +}); |
| 40 | + |
| 41 | +afterAll(async () => { |
| 42 | + await rm(tempDir, { force: true, recursive: true }); |
3 | 43 | });
|
0 commit comments