@@ -34,6 +34,52 @@ func TestHTTPControlPlaneClientSessionPathFallsBackToWorkspaceRoute(t *testing.T
3434 }
3535}
3636
37+ func TestHTTPControlPlaneClientAddWorkspaceCompositionMountAcceptsCreated (t * testing.T ) {
38+ t .Helper ()
39+
40+ server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
41+ if r .Method != http .MethodPost {
42+ t .Fatalf ("method = %s, want POST" , r .Method )
43+ }
44+ if r .URL .Path != "/v2/workspaces/ws_agent/mounts" {
45+ t .Fatalf ("path = %q, want workspace composition mounts route" , r .URL .Path )
46+ }
47+ var req controlplane.WorkspaceCompositionMount
48+ if err := json .NewDecoder (r .Body ).Decode (& req ); err != nil {
49+ t .Fatalf ("Decode(request) returned error: %v" , err )
50+ }
51+ if req .VolumeID != "ws_volume" || req .MountPath != "/repo" {
52+ t .Fatalf ("request = %+v, want selected volume at /repo" , req )
53+ }
54+ w .WriteHeader (http .StatusCreated )
55+ _ = json .NewEncoder (w ).Encode (controlplane.WorkspaceCompositionDetail {
56+ ID : "ws_agent" ,
57+ Name : "coding-agent" ,
58+ Mounts : []controlplane.WorkspaceCompositionMount {{
59+ VolumeID : "ws_volume" ,
60+ VolumeName : "repo" ,
61+ MountPath : "/repo" ,
62+ }},
63+ })
64+ }))
65+ defer server .Close ()
66+
67+ client := & httpControlPlaneClient {
68+ baseURL : server .URL ,
69+ client : & http.Client {Timeout : time .Minute },
70+ }
71+ detail , err := client .AddWorkspaceCompositionMount (context .Background (), "ws_agent" , controlplane.WorkspaceCompositionMount {
72+ VolumeID : "ws_volume" ,
73+ MountPath : "/repo" ,
74+ })
75+ if err != nil {
76+ t .Fatalf ("AddWorkspaceCompositionMount() returned error: %v" , err )
77+ }
78+ if detail .Name != "coding-agent" || len (detail .Mounts ) != 1 || detail .Mounts [0 ].VolumeID != "ws_volume" {
79+ t .Fatalf ("detail = %+v, want attached volume response" , detail )
80+ }
81+ }
82+
3783func TestHTTPControlPlaneClientQueryUsesLongRunningClient (t * testing.T ) {
3884 t .Helper ()
3985
0 commit comments