@@ -263,6 +263,68 @@ func TestCreateSandbox_FromSnapshot(t *testing.T) {
263263 require .NoErrorf (t , err , "CreateSandbox from snapshot" )
264264}
265265
266+ func TestCreateSandbox_Platform (t * testing.T ) {
267+ _ , client := newLifecycleServer (t , func (w http.ResponseWriter , r * http.Request ) {
268+ var req CreateSandboxRequest
269+ if err := json .NewDecoder (r .Body ).Decode (& req ); err != nil {
270+ assert .Fail (t , fmt .Sprintf ("decode request: %v" , err ))
271+ return
272+ }
273+ require .NotNil (t , req .Platform , "expected Platform to be sent in the request" )
274+ require .Equal (t , OSWindows , req .Platform .OS , "Platform.OS" )
275+ require .Equal (t , ArchAMD64 , req .Platform .Arch , "Platform.Arch" )
276+
277+ jsonResponse (w , http .StatusCreated , SandboxInfo {
278+ ID : "sbx-windows" ,
279+ Status : SandboxStatus {State : StatePending },
280+ Platform : & PlatformSpec {OS : OSWindows , Arch : ArchAMD64 },
281+ CreatedAt : time .Now ().UTC ().Truncate (time .Second ),
282+ })
283+ })
284+
285+ info , err := client .CreateSandbox (context .Background (), CreateSandboxRequest {
286+ Image : & ImageSpec {URI : "dockurr/windows:latest" },
287+ Entrypoint : []string {"cmd" , "/c" , "echo hi" },
288+ ResourceLimits : ResourceLimits {"cpu" : "2" , "memory" : "4G" , "disk" : "64G" },
289+ Platform : & PlatformSpec {OS : OSWindows , Arch : ArchAMD64 },
290+ })
291+ require .NoErrorf (t , err , "CreateSandbox with Platform" )
292+ require .NotNil (t , info .Platform , "response should echo Platform" )
293+ require .Equal (t , OSWindows , info .Platform .OS , "echoed Platform.OS" )
294+ require .Equal (t , ArchAMD64 , info .Platform .Arch , "echoed Platform.Arch" )
295+ }
296+
297+ func TestCreateSandbox_PlatformOmittedWhenNil (t * testing.T ) {
298+ _ , client := newLifecycleServer (t , func (w http.ResponseWriter , r * http.Request ) {
299+ body , err := io .ReadAll (r .Body )
300+ if err != nil {
301+ assert .Fail (t , fmt .Sprintf ("read request body: %v" , err ))
302+ return
303+ }
304+ var raw map [string ]json.RawMessage
305+ if err := json .Unmarshal (body , & raw ); err != nil {
306+ assert .Fail (t , fmt .Sprintf ("unmarshal request body: %v" , err ))
307+ return
308+ }
309+ if _ , present := raw ["platform" ]; present {
310+ assert .Fail (t , "platform should be omitted from JSON when nil" )
311+ }
312+
313+ jsonResponse (w , http .StatusCreated , SandboxInfo {
314+ ID : "sbx-no-platform" ,
315+ Status : SandboxStatus {State : StatePending },
316+ CreatedAt : time .Now ().UTC ().Truncate (time .Second ),
317+ })
318+ })
319+
320+ _ , err := client .CreateSandbox (context .Background (), CreateSandboxRequest {
321+ Image : & ImageSpec {URI : "python:3.12" },
322+ Entrypoint : []string {"/bin/sh" },
323+ ResourceLimits : ResourceLimits {"cpu" : "500m" },
324+ })
325+ require .NoErrorf (t , err , "CreateSandbox without Platform" )
326+ }
327+
266328func TestGetSandbox (t * testing.T ) {
267329 want := SandboxInfo {
268330 ID : "sbx-456" ,
0 commit comments