MCPcopy Create free account
hub / github.com/astercloud/aster / TestContextInjector_InjectSessionState

Function TestContextInjector_InjectSessionState

pkg/context/auto_inject_test.go:64–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestContextInjector_InjectSessionState(t *testing.T) {
65 state := &SessionState{
66 SessionID: "session-123",
67 MessageCount: 42,
68 Duration: 30 * time.Minute,
69 CustomState: map[string]any{
70 "mode": "debug",
71 },
72 }
73
74 config := InjectorConfig{
75 EnableSessionState: true,
76 SessionStateProvider: NewSimpleSessionStateProvider(state),
77 }
78
79 injector := NewContextInjector(config)
80 systemPrompt := "You are a helpful assistant."
81
82 result := injector.InjectContext(context.Background(), systemPrompt)
83
84 if !strings.Contains(result, "Session State") {
85 t.Error("expected session state context to be injected")
86 }
87
88 if !strings.Contains(result, "session-123") {
89 t.Error("expected session ID to be included")
90 }
91
92 if !strings.Contains(result, "42") {
93 t.Error("expected message count to be included")
94 }
95}
96
97func TestContextInjector_MultipleContexts(t *testing.T) {
98 config := InjectorConfig{

Callers

nothing calls this directly

Calls 4

InjectContextMethod · 0.95
NewContextInjectorFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected