Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
104 lines
2.6 KiB
Go
104 lines
2.6 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
tuttigenerated "github.com/tutti-os/tutti/services/tuttid/api/generated"
|
|
workspacebiz "github.com/tutti-os/tutti/services/tuttid/biz/workspace"
|
|
workspaceservice "github.com/tutti-os/tutti/services/tuttid/service/workspace"
|
|
)
|
|
|
|
type rejectingWorkbenchStore struct {
|
|
t *testing.T
|
|
}
|
|
|
|
func (s rejectingWorkbenchStore) GetWorkbenchSnapshot(context.Context, string) (workspacebiz.WorkbenchSnapshot, error) {
|
|
s.t.Fatal("GetWorkbenchSnapshot should not be called")
|
|
return workspacebiz.WorkbenchSnapshot{}, nil
|
|
}
|
|
|
|
func (s rejectingWorkbenchStore) PutWorkbenchSnapshot(context.Context, workspacebiz.WorkbenchSnapshot) error {
|
|
s.t.Fatal("PutWorkbenchSnapshot should not be called for invalid workbench snapshots")
|
|
return nil
|
|
}
|
|
|
|
func TestDaemonAPIWorkbenchRejectsInvalidSnapshotBeforeStore(t *testing.T) {
|
|
mux := http.NewServeMux()
|
|
RegisterRoutes(
|
|
mux,
|
|
NewRoutes(DaemonAPI{
|
|
WorkbenchService: workspaceservice.WorkbenchService{
|
|
Store: rejectingWorkbenchStore{t: t},
|
|
},
|
|
},
|
|
),
|
|
)
|
|
|
|
recorder := performGeneratedRouteRequest(t, mux, http.MethodPut, "/v1/workspaces/ws-1/workbench", map[string]any{
|
|
"snapshot": map[string]any{
|
|
"schemaVersion": 1,
|
|
"nodes": []map[string]any{
|
|
{
|
|
"id": "node-1",
|
|
"kind": "terminal",
|
|
"title": "Terminal",
|
|
"frame": map[string]any{
|
|
"x": 10,
|
|
"y": 20,
|
|
"width": 120,
|
|
"height": 240,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
if recorder.Code != http.StatusBadRequest {
|
|
t.Fatalf("status = %d, want %d; body: %s", recorder.Code, http.StatusBadRequest, recorder.Body.String())
|
|
}
|
|
}
|
|
|
|
func TestDaemonAPIWorkbenchRejectsUnknownSnapshotFields(t *testing.T) {
|
|
mux := http.NewServeMux()
|
|
RegisterRoutes(
|
|
mux,
|
|
NewRoutes(DaemonAPI{
|
|
WorkbenchService: workspaceservice.WorkbenchService{
|
|
Store: rejectingWorkbenchStore{t: t},
|
|
},
|
|
},
|
|
),
|
|
)
|
|
|
|
recorder := performGeneratedRouteRequest(t, mux, http.MethodPut, "/v1/workspaces/ws-1/workbench", map[string]any{
|
|
"snapshot": map[string]any{
|
|
"schemaVersion": 1,
|
|
"nodes": []map[string]any{
|
|
{
|
|
"id": "node-1",
|
|
"kind": "terminal",
|
|
"title": "Terminal",
|
|
"position": map[string]any{"x": 10, "y": 20},
|
|
"frame": map[string]any{
|
|
"x": 10,
|
|
"y": 20,
|
|
"width": 320,
|
|
"height": 240,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
if recorder.Code != http.StatusBadRequest {
|
|
t.Fatalf("status = %d, want %d; body: %s", recorder.Code, http.StatusBadRequest, recorder.Body.String())
|
|
}
|
|
assertGeneratedRouteError(
|
|
t,
|
|
recorder,
|
|
tuttigenerated.InvalidRequest,
|
|
"malformed_request",
|
|
"can't decode JSON body: json: unknown field \"position\"",
|
|
)
|
|
}
|