Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions apps/server/src/project/ProjectService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Metric from "effect/Metric";
import * as Option from "effect/Option";
import * as Path from "effect/Path";
import * as PubSub from "effect/PubSub";
import * as Ref from "effect/Ref";
import { TestClock } from "effect/testing";
Expand Down Expand Up @@ -352,13 +353,14 @@ it.layer(layerTest)("ProjectService", (it) => {
const service = yield* ProjectService.ProjectService;
const projectId = ProjectId.make("project:tracked-folders");
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const work = yield* fileSystem.realPath(
yield* fileSystem.makeTempDirectoryScoped({ prefix: "project-tracked-" }),
);
yield* fileSystem.makeDirectory(`${work}/app/packages/web`, { recursive: true });
yield* fileSystem.makeDirectory(`${work}/api`);
yield* fileSystem.writeFileString(`${work}/notes.txt`, "not a folder\n");
const folder = (path: string) => ({ path, name: "Folder" });
const folder = (folderPath: string) => ({ path: folderPath, name: "Folder" });
const invalid = [
["relative", [folder("sibling")]],
["own-folder", [folder(`${work}/app/`)]],
Expand Down Expand Up @@ -389,7 +391,7 @@ it.layer(layerTest)("ProjectService", (it) => {
"ProjectInvalidError",
);
}
const tracked = [folder(`${work}/api`), folder(`${work}/app/packages/web`)];
const tracked = [folder(path.join(work, "api")), folder(path.join(work, "app/packages/web"))];
const created = yield* create("valid", [folder(`${work}/api/`), tracked[1]!]);
assert.deepEqual(created.trackedFolders, tracked);

Expand Down Expand Up @@ -433,7 +435,7 @@ it.layer(layerTest)("ProjectService", (it) => {
);
yield* fileSystem.makeDirectory(`${moved}/web/.git`, { recursive: true });
assert.deepEqual((yield* update("move", { workspaceRoot: moved })).trackedFolders, [
{ path: `${moved}/web`, name: "web", discovered: true },
{ path: path.join(moved, "web"), name: "web", discovered: true },
]);
}).pipe(Effect.provide(NodeServices.layer)),
);
Expand Down Expand Up @@ -1034,6 +1036,7 @@ it.effect("serializes two projects claiming the same workspace root", () =>
it.effect("keeps a folder added while a scan of the project folder waited to commit", () =>
Effect.gen(function* () {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const root = yield* fileSystem.realPath(
yield* fileSystem.makeTempDirectoryScoped({ prefix: "project-folder-sync-" }),
);
Expand Down Expand Up @@ -1084,7 +1087,7 @@ it.effect("keeps a folder added while a scan of the project folder waited to com
yield* Fiber.join(update);
yield* Deferred.await(synced);
assert.deepEqual(Option.getOrThrow(yield* service.getById(projectId)).trackedFolders, [
{ path: `${root}/api`, name: "api", discovered: true },
{ path: path.join(root, "api"), name: "api", discovered: true },
added,
]);
}).pipe(Effect.provide(layerProjectServiceDependencies)),
Expand Down
Loading