@@ -2,6 +2,7 @@ import { describe, expect, it } from "@effect/vitest"
22import { Effect , Either } from "effect"
33
44import { type Command , defaultTemplateConfig } from "@effect-template/lib/core/domain"
5+ import { expandContainerHome } from "@effect-template/lib/usecases/scrap-path"
56import { parseArgs } from "../../src/docker-git/cli/parser.js"
67
78type CreateCommand = Extract < Command , { _tag : "Create" } >
@@ -52,6 +53,8 @@ const expectCreateDefaults = (command: CreateCommand) => {
5253 expect ( command . forceEnv ) . toBe ( false )
5354}
5455
56+ const expandDefaultTargetDir = ( path : string ) : string => expandContainerHome ( defaultTemplateConfig . sshUser , path )
57+
5558describe ( "parseArgs" , ( ) => {
5659 it . effect ( "parses create command with defaults" , ( ) =>
5760 expectCreateCommand ( [ "create" , "--repo-url" , "https://github.com/org/repo.git" ] , ( command ) => {
@@ -83,7 +86,9 @@ describe("parseArgs", () => {
8386 expectCreateDefaults ( command )
8487 expect ( command . openSsh ) . toBe ( true )
8588 expect ( command . waitForClone ) . toBe ( true )
86- expect ( command . config . targetDir ) . toBe ( "~/.docker-git/workspaces/org/repo" )
89+ expect ( command . config . targetDir ) . toBe (
90+ expandDefaultTargetDir ( "~/.docker-git/workspaces/org/repo" )
91+ )
8792 } ) )
8893
8994 it . effect ( "parses clone branch alias" , ( ) =>
@@ -118,15 +123,19 @@ describe("parseArgs", () => {
118123 expect ( command . config . repoUrl ) . toBe ( "https://github.com/agiens/crm.git" )
119124 expect ( command . config . repoRef ) . toBe ( "vova-fork" )
120125 expect ( command . outDir ) . toBe ( ".docker-git/agiens/crm" )
121- expect ( command . config . targetDir ) . toBe ( "~/.docker-git/workspaces/agiens/crm" )
126+ expect ( command . config . targetDir ) . toBe (
127+ expandDefaultTargetDir ( "~/.docker-git/workspaces/agiens/crm" )
128+ )
122129 } ) )
123130
124131 it . effect ( "parses GitHub issue url as isolated project + issue branch" , ( ) =>
125132 expectCreateCommand ( [ "clone" , "https://github.com/org/repo/issues/5" ] , ( command ) => {
126133 expect ( command . config . repoUrl ) . toBe ( "https://github.com/org/repo.git" )
127134 expect ( command . config . repoRef ) . toBe ( "issue-5" )
128135 expect ( command . outDir ) . toBe ( ".docker-git/org/repo/issue-5" )
129- expect ( command . config . targetDir ) . toBe ( "~/.docker-git/workspaces/org/repo/issue-5" )
136+ expect ( command . config . targetDir ) . toBe (
137+ expandDefaultTargetDir ( "~/.docker-git/workspaces/org/repo/issue-5" )
138+ )
130139 expect ( command . config . containerName ) . toBe ( "dg-repo-issue-5" )
131140 expect ( command . config . serviceName ) . toBe ( "dg-repo-issue-5" )
132141 expect ( command . config . volumeName ) . toBe ( "dg-repo-issue-5-home" )
@@ -137,7 +146,9 @@ describe("parseArgs", () => {
137146 expect ( command . config . repoUrl ) . toBe ( "https://github.com/org/repo.git" )
138147 expect ( command . config . repoRef ) . toBe ( "refs/pull/42/head" )
139148 expect ( command . outDir ) . toBe ( ".docker-git/org/repo/pr-42" )
140- expect ( command . config . targetDir ) . toBe ( "~/.docker-git/workspaces/org/repo/pr-42" )
149+ expect ( command . config . targetDir ) . toBe (
150+ expandDefaultTargetDir ( "~/.docker-git/workspaces/org/repo/pr-42" )
151+ )
141152 expect ( command . config . containerName ) . toBe ( "dg-repo-pr-42" )
142153 expect ( command . config . serviceName ) . toBe ( "dg-repo-pr-42" )
143154 expect ( command . config . volumeName ) . toBe ( "dg-repo-pr-42-home" )
0 commit comments