forked from agent-dance/agent-adaptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession_codec_internal_test.go
More file actions
51 lines (42 loc) · 1.52 KB
/
Copy pathsession_codec_internal_test.go
File metadata and controls
51 lines (42 loc) · 1.52 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package agentadaptor
import (
"context"
"testing"
)
type passthroughCodecDriver struct{}
func (passthroughCodecDriver) Descriptor() DriverDescriptor {
return DriverDescriptor{Type: "passthrough", DisplayName: "Passthrough"}
}
func (passthroughCodecDriver) ValidateConfig(any) error { return nil }
func (passthroughCodecDriver) Run(_ context.Context, _ DriverRunRequest, _ EventSink) (DriverRunResult, error) {
return DriverRunResult{}, nil
}
func TestSessionCodecForFallsBackToPassthrough(t *testing.T) {
driver := passthroughCodecDriver{}
codec := SessionCodecFor(driver)
state := &DriverSessionState{
ResumeID: "resume-1",
Data: map[string]string{
SessionParamCWD: "C:/workspace",
},
}
params := codec.ToParams(state)
if params.ResumeID != "resume-1" {
t.Fatalf("expected resume id to round-trip, got %#v", params)
}
if params.DisplayID != "resume-1" {
t.Fatalf("expected display id to default to resume id, got %#v", params)
}
if params.Values[SessionParamCWD] != "C:/workspace" {
t.Fatalf("expected session values to round-trip, got %#v", params.Values)
}
restored := codec.FromParams(params)
if restored == nil || restored.ResumeID != state.ResumeID || restored.DisplayID != state.ResumeID {
t.Fatalf("expected restored state, got %#v", restored)
}
firstGuard := codec.GuardFingerprint(params)
secondGuard := codec.GuardFingerprint(codec.ToParams(restored))
if firstGuard == "" || firstGuard != secondGuard {
t.Fatalf("expected stable guard fingerprint, got %q and %q", firstGuard, secondGuard)
}
}