-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscope_entity_test.go
More file actions
35 lines (31 loc) · 937 Bytes
/
Copy pathscope_entity_test.go
File metadata and controls
35 lines (31 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cortex_test
import (
"encoding/json"
"testing"
"github.com/xraph/cortex"
"github.com/xraph/cortex/agent"
"github.com/xraph/cortex/run"
)
func TestRun_CarriesScope(t *testing.T) {
r := run.Run{Scope: cortex.Scope{Levels: []cortex.Level{{Key: "workspace", Value: "ws_x"}}}}
if got := r.Scope.Canonical(); got != "workspace=ws_x" {
t.Errorf("run scope = %q, want workspace=ws_x", got)
}
}
func TestAgentConfig_ScopeSurvivesJSON(t *testing.T) {
c := agent.Config{
Name: "assistant",
Scope: cortex.Scope{Levels: []cortex.Level{{Key: "workspace", Value: "ws_x"}}},
}
blob, err := json.Marshal(&c)
if err != nil {
t.Fatalf("marshal: %v", err)
}
var back agent.Config
if err := json.Unmarshal(blob, &back); err != nil {
t.Fatalf("unmarshal: %v", err)
}
if back.Scope.Canonical() != c.Scope.Canonical() {
t.Errorf("scope after round trip = %q, want %q", back.Scope.Canonical(), c.Scope.Canonical())
}
}