返回 DeepSeek-Reasonix
host_command_owners_test.go
根目录 / desktop / host_command_owners_test.go
1 package main
2
3 import (
4 "encoding/json"
5 "reflect"
6 "testing"
7
8 "reasonix/desktop/internal/hostrpc"
9 )
10
11 func TestHostCommandOwnersMatchSource(t *testing.T) {
12 want, err := hostrpc.SourceOwnership(".", "App")
13 if err != nil {
14 t.Fatal(err)
15 }
16 var got map[string]hostrpc.CommandOwnership
17 if err := json.Unmarshal(hostCommandOwnersJSON, &got); err != nil {
18 t.Fatal(err)
19 }
20 if !reflect.DeepEqual(got, want) {
21 t.Fatal("host command ownership drift; run go run . -emit-contract frontend/src/generated")
22 }
23 registry, err := newDesktopRegistry((*App)(nil))
24 if err != nil {
25 t.Fatal(err)
26 }
27 if len(registry.Commands()) != len(got) {
28 t.Fatalf("source owners %d != reflected commands %d", len(got), len(registry.Commands()))
29 }
30 for _, cmd := range registry.Commands() {
31 if cmd.Cancellation != "before-dispatch" {
32 t.Errorf("%s unexpectedly promises cooperative cancellation", cmd.Name)
33 }
34 }
35 }
36
36 lines GO