mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-23 05:52:02 +00:00
60 lines
2.6 KiB
TypeScript
60 lines
2.6 KiB
TypeScript
import { assert, it } from "@effect/vitest";
|
|
import * as Effect from "effect/Effect";
|
|
import * as Layer from "effect/Layer";
|
|
|
|
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
import * as FileSystem from "effect/FileSystem";
|
|
|
|
import * as ServerConfig from "../config.ts";
|
|
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
|
import * as GitManager from "./GitManager.ts";
|
|
import * as GitWorkflowService from "./GitWorkflowService.ts";
|
|
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
|
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
|
|
|
it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("GitWorkflowService", (it) => {
|
|
it.effect("finds a name among the refs of every namespace", () =>
|
|
Effect.gen(function* () {
|
|
const fileSystem = yield* FileSystem.FileSystem;
|
|
const cwd = yield* fileSystem.makeTempDirectoryScoped({ prefix: "hanzo-ref-named-" });
|
|
const workflow = yield* GitWorkflowService.GitWorkflowService;
|
|
const driver = yield* GitVcsDriver.GitVcsDriver;
|
|
for (const args of [
|
|
["init", "-b", "main"],
|
|
["-c", "user.email=t@t", "-c", "user.name=t", "commit", "--allow-empty", "-m", "init"],
|
|
["update-ref", "refs/remotes/upstream/feature/topic", "HEAD"],
|
|
["symbolic-ref", "refs/remotes/origin/alias", "refs/heads/main"],
|
|
["update-ref", "refs/mirror/origin/mirrored", "HEAD"],
|
|
]) {
|
|
yield* driver.execute({ operation: "test.setupRepo", cwd, args });
|
|
}
|
|
const found = yield* Effect.forEach(
|
|
["main", "feature/topic", "alias", "mirrored", "hanzo/renamed", "feature/*"],
|
|
(refName) => workflow.hasRefNamed({ cwd, refName }),
|
|
);
|
|
assert.deepEqual(found, [true, true, true, true, false, false]);
|
|
}).pipe(
|
|
Effect.scoped,
|
|
Effect.provide(
|
|
GitWorkflowService.layer.pipe(
|
|
Layer.provide(
|
|
Layer.mock(VcsDriverRegistry.VcsDriverRegistry)({
|
|
resolve: () => Effect.succeed({ kind: "git" } as VcsDriverRegistry.VcsDriverHandle),
|
|
}),
|
|
),
|
|
Layer.provide(Layer.mock(GitManager.GitManager)({})),
|
|
Layer.provideMerge(GitVcsDriver.layer),
|
|
Layer.provideMerge(VcsProcess.layer),
|
|
Layer.provideMerge(
|
|
ServerConfig.layerTest(process.cwd(), { prefix: "hanzo-ref-named-" }).pipe(
|
|
Layer.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
|
|
),
|
|
),
|
|
Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|