MCPcopy Create free account
hub / github.com/compozy/agh / TestWorkspaceAddBuildsRequest

Function TestWorkspaceAddBuildsRequest

internal/cli/workspace_test.go:10–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestWorkspaceAddBuildsRequest(t *testing.T) {
11 t.Parallel()
12
13 tests := []struct {
14 name string
15 args []string
16 request WorkspaceCreateRequest
17 }{
18 {
19 name: "minimal",
20 args: []string{"workspace", "add", "/workspace/project", "-o", "json"},
21 request: WorkspaceCreateRequest{
22 RootDir: "/workspace/project",
23 },
24 },
25 {
26 name: "with optional flags",
27 args: []string{
28 "workspace", "add", "/workspace/project",
29 "--name", "alpha",
30 "--add-dir", "/workspace/shared-a",
31 "--add-dir", "/workspace/shared-b",
32 "--default-agent", "coder",
33 "--sandbox", "daytona-dev",
34 "-o", "json",
35 },
36 request: WorkspaceCreateRequest{
37 RootDir: "/workspace/project",
38 Name: "alpha",
39 AddDirs: []string{"/workspace/shared-a", "/workspace/shared-b"},
40 DefaultAgent: "coder",
41 SandboxRef: "daytona-dev",
42 },
43 },
44 }
45
46 for _, tt := range tests {
47 t.Run(tt.name, func(t *testing.T) {
48 t.Parallel()
49
50 deps := newTestDeps(t, &stubClient{
51 createWorkspaceFn: func(_ context.Context, request WorkspaceCreateRequest) (WorkspaceRecord, error) {
52 if request.RootDir != tt.request.RootDir || request.Name != tt.request.Name ||
53 request.DefaultAgent != tt.request.DefaultAgent ||
54 request.SandboxRef != tt.request.SandboxRef {
55 t.Fatalf("CreateWorkspace() request = %#v, want %#v", request, tt.request)
56 }
57 if strings.Join(request.AddDirs, ",") != strings.Join(tt.request.AddDirs, ",") {
58 t.Fatalf("CreateWorkspace() AddDirs = %#v, want %#v", request.AddDirs, tt.request.AddDirs)
59 }
60 return WorkspaceRecord{
61 ID: "ws_alpha",
62 RootDir: request.RootDir,
63 AddDirs: request.AddDirs,
64 Name: firstNonEmpty(request.Name, "alpha"),
65 DefaultAgent: request.DefaultAgent,
66 SandboxRef: request.SandboxRef,
67 CreatedAt: fixedTestNow,

Callers

nothing calls this directly

Calls 4

newTestDepsFunction · 0.85
executeRootCommandFunction · 0.85
firstNonEmptyFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected