Showing the changes to apps/server/src/sourceControl/SourceControlRepositoryService.test.ts (1 of 59 files). Show all
Unified · Split
| @@ -6,14 +6,10 @@ import { ChildProcessSpawner } from "effect/unstable/process"; · 5 unmodified lines | |||
| 6 | import { GitCommandError, type SourceControlProviderError } from "@t3tools/contracts"; | 6 | import { GitCommandError, type SourceControlProviderError } from "@t3tools/contracts"; |
| 7 | 7 | ||
| 8 | import { ServerConfig } from "../config.ts"; | 8 | import { ServerConfig } from "../config.ts"; |
| 9 | import { | 9 | import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; |
| 10 | GitVcsDriver, | 10 | import type * as SourceControlProvider from "./SourceControlProvider.ts"; |
| 11 | type ExecuteGitResult, | 11 | import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts"; |
| 12 | type GitVcsDriverShape, | 12 | import * as SourceControlRepositoryService from "./SourceControlRepositoryService.ts"; |
| 13 | } from "../vcs/GitVcsDriver.ts"; | ||
| 14 | import { SourceControlProviderRegistry } from "./SourceControlProviderRegistry.ts"; | ||
| 15 | import type { SourceControlProviderShape } from "./SourceControlProvider.ts"; | ||
| 16 | import { SourceControlRepositoryService, layer } from "./SourceControlRepositoryService.ts"; | ||
| 17 | 13 | ||
| 18 | const CLONE_URLS = { | 14 | const CLONE_URLS = { |
| 19 | nameWithOwner: "octocat/t3code", | 15 | nameWithOwner: "octocat/t3code", |
| @@ -22,8 +18,8 @@ const CLONE_URLS = { · 2 unmodified lines | |||
| 22 | }; | 18 | }; |
| 23 | 19 | ||
| 24 | function makeProvider( | 20 | function makeProvider( |
| 25 | overrides: Partial<SourceControlProviderShape> = {}, | 21 | overrides: Partial<SourceControlProvider.SourceControlProviderShape> = {}, |
| 26 | ): SourceControlProviderShape { | 22 | ): SourceControlProvider.SourceControlProviderShape { |
| 27 | const unsupported = (operation: string) => | 23 | const unsupported = (operation: string) => |
| 28 | Effect.die(`unexpected provider operation ${operation}`) as Effect.Effect< | 24 | Effect.die(`unexpected provider operation ${operation}`) as Effect.Effect< |
| 29 | never, | 25 | never, |
| @@ -43,7 +39,7 @@ function makeProvider( · 13 unmodified lines | |||
| 43 | }; | 39 | }; |
| 44 | } | 40 | } |
| 45 | 41 | ||
| 46 | function processOutput(): ExecuteGitResult { | 42 | function processOutput(): GitVcsDriver.ExecuteGitResult { |
| 47 | return { | 43 | return { |
| 48 | exitCode: ChildProcessSpawner.ExitCode(0), | 44 | exitCode: ChildProcessSpawner.ExitCode(0), |
| 49 | stdout: "", | 45 | stdout: "", |
| @@ -54,17 +50,17 @@ function processOutput(): ExecuteGitResult { · 4 unmodified lines | |||
| 54 | } | 50 | } |
| 55 | 51 | ||
| 56 | function makeLayer(input: { | 52 | function makeLayer(input: { |
| 57 | readonly provider?: SourceControlProviderShape; | 53 | readonly provider?: SourceControlProvider.SourceControlProviderShape; |
| 58 | readonly git?: Partial<GitVcsDriverShape>; | 54 | readonly git?: Partial<GitVcsDriver.GitVcsDriverShape>; |
| 59 | }) { | 55 | }) { |
| 60 | return layer.pipe( | 56 | return SourceControlRepositoryService.layer.pipe( |
| 61 | Layer.provide( | 57 | Layer.provide( |
| 62 | Layer.mock(SourceControlProviderRegistry)({ | 58 | Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({ |
| 63 | get: () => Effect.succeed(input.provider ?? makeProvider()), | 59 | get: () => Effect.succeed(input.provider ?? makeProvider()), |
| 64 | }), | 60 | }), |
| 65 | ), | 61 | ), |
| 66 | Layer.provide( | 62 | Layer.provide( |
| 67 | Layer.mock(GitVcsDriver)({ | 63 | Layer.mock(GitVcsDriver.GitVcsDriver)({ |
| 68 | execute: () => Effect.succeed(processOutput()), | 64 | execute: () => Effect.succeed(processOutput()), |
| 69 | ensureRemote: () => Effect.succeed("origin"), | 65 | ensureRemote: () => Effect.succeed("origin"), |
| 70 | pushCurrentBranch: () => | 66 | pushCurrentBranch: () => |
| @@ -93,7 +89,7 @@ it.effect("looks up repositories through the requested provider without search", · 22 unmodified lines | |||
| 93 | }); | 89 | }); |
| 94 | 90 | ||
| 95 | return Effect.gen(function* () { | 91 | return Effect.gen(function* () { |
| 96 | const service = yield* SourceControlRepositoryService; | 92 | const service = yield* SourceControlRepositoryService.SourceControlRepositoryService; |
| 97 | const result = yield* service.lookupRepository({ | 93 | const result = yield* service.lookupRepository({ |
| 98 | provider: "github", | 94 | provider: "github", |
| 99 | repository: "octocat/t3code", | 95 | repository: "octocat/t3code", |
| @@ -115,7 +111,7 @@ it.effect("clones a looked-up repository into the requested destination", () => · 15 unmodified lines | |||
| 115 | const cloneCalls: Array<{ cwd: string; args: ReadonlyArray<string> }> = []; | 111 | const cloneCalls: Array<{ cwd: string; args: ReadonlyArray<string> }> = []; |
| 116 | 112 | ||
| 117 | yield* Effect.gen(function* () { | 113 | yield* Effect.gen(function* () { |
| 118 | const service = yield* SourceControlRepositoryService; | 114 | const service = yield* SourceControlRepositoryService.SourceControlRepositoryService; |
| 119 | const result = yield* service.cloneRepository({ | 115 | const result = yield* service.cloneRepository({ |
| 120 | provider: "github", | 116 | provider: "github", |
| 121 | repository: "octocat/t3code", | 117 | repository: "octocat/t3code", |
| @@ -167,7 +163,7 @@ it.effect("publishes by creating the repository, adding a remote, and pushing up · 45 unmodified lines | |||
| 167 | }); | 163 | }); |
| 168 | 164 | ||
| 169 | return Effect.gen(function* () { | 165 | return Effect.gen(function* () { |
| 170 | const service = yield* SourceControlRepositoryService; | 166 | const service = yield* SourceControlRepositoryService.SourceControlRepositoryService; |
| 171 | const result = yield* service.publishRepository({ | 167 | const result = yield* service.publishRepository({ |
| 172 | cwd: "/workspace", | 168 | cwd: "/workspace", |
| 173 | provider: "github", | 169 | provider: "github", |
| @@ -222,7 +218,7 @@ it.effect("publishes to the remote name returned by ensureRemote", () => { · 48 unmodified lines | |||
| 222 | const pushCalls: Array<{ cwd: string; remoteName: string | null | undefined }> = []; | 218 | const pushCalls: Array<{ cwd: string; remoteName: string | null | undefined }> = []; |
| 223 | 219 | ||
| 224 | return Effect.gen(function* () { | 220 | return Effect.gen(function* () { |
| 225 | const service = yield* SourceControlRepositoryService; | 221 | const service = yield* SourceControlRepositoryService.SourceControlRepositoryService; |
| 226 | const result = yield* service.publishRepository({ | 222 | const result = yield* service.publishRepository({ |
| 227 | cwd: "/workspace", | 223 | cwd: "/workspace", |
| 228 | provider: "github", | 224 | provider: "github", |
| @@ -258,7 +254,7 @@ it.effect("publishes to the remote name returned by ensureRemote", () => { · 29 unmodified lines | |||
| 258 | it.effect("publish succeeds with status remote_added when the local repo has no commits", () => { | 254 | it.effect("publish succeeds with status remote_added when the local repo has no commits", () => { |
| 259 | let pushCalls = 0; | 255 | let pushCalls = 0; |
| 260 | return Effect.gen(function* () { | 256 | return Effect.gen(function* () { |
| 261 | const service = yield* SourceControlRepositoryService; | 257 | const service = yield* SourceControlRepositoryService.SourceControlRepositoryService; |
| 262 | const result = yield* service.publishRepository({ | 258 | const result = yield* service.publishRepository({ |
| 263 | cwd: "/workspace", | 259 | cwd: "/workspace", |
| 264 | provider: "github", | 260 | provider: "github", |