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

Function TestInMemoryService_StateScopes

pkg/session/inmemory_test.go:588–661  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

586}
587
588func TestInMemoryService_StateScopes(t *testing.T) {
589 t.Skip("Skipping: inmemory service implementation has issues with state scopes")
590 ctx := context.Background()
591
592 t.Run("状态作用域隔离", func(t *testing.T) {
593 service := NewInMemoryService()
594 sess, _ := service.Create(ctx, &CreateRequest{
595 AppName: "test-app",
596 UserID: "user-1",
597 AgentID: "agent-1",
598 })
599 // App 级状态(所有用户共享)
600 if err := service.AppendEvent(ctx, sess.ID(), &Event{
601 ID: "evt-1",
602 Timestamp: time.Now(),
603 InvocationID: "inv-1",
604 AgentID: "agent-1",
605 Branch: "root",
606 Author: "system",
607 Actions: EventActions{
608 StateDelta: map[string]any{
609 "app:feature_enabled": true,
610 },
611 },
612 }); err != nil {
613 t.Fatalf("AppendEvent failed: %v", err)
614 }
615
616 // User 级状态(该用户所有会话共享)
617 if err := service.AppendEvent(ctx, sess.ID(), &Event{
618 ID: "evt-2",
619 Timestamp: time.Now(),
620 InvocationID: "inv-1",
621 AgentID: "agent-1",
622 Branch: "root",
623 Author: "system",
624 Actions: EventActions{
625 StateDelta: map[string]any{
626 "user:preference": "value",
627 },
628 },
629 }); err != nil {
630 t.Fatalf("AppendEvent failed: %v", err)
631 }
632
633 // Session 级状态(当前会话)
634 if err := service.AppendEvent(ctx, sess.ID(), &Event{
635 ID: "evt-3",
636 Timestamp: time.Now(),
637 InvocationID: "inv-1",
638 AgentID: "agent-1",
639 Branch: "root",
640 Author: "system",
641 Actions: EventActions{
642 StateDelta: map[string]any{
643 "session:data": "session-specific",
644 },
645 },

Callers

nothing calls this directly

Calls 8

CreateMethod · 0.95
AppendEventMethod · 0.95
GetMethod · 0.95
NewInMemoryServiceFunction · 0.85
IDMethod · 0.65
StateMethod · 0.65
HasMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected