源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
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
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
This commit is contained in:
commit
2ed3415fb7
8018 files changed
+1936476
No files matched your search
@@ -0,0 +1,103 @@
|
||||
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\"",
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user