(t *testing.T)
| 33 | func (a *dummyAgent) Close() error { return nil } |
| 34 | |
| 35 | func TestServer_Fork(t *testing.T) { |
| 36 | ctx := context.Background() |
| 37 | srcCID := "src-conv" |
| 38 | destCID := "dest-conv" |
| 39 | |
| 40 | log := &executortest.MemoryEventLog{} |
| 41 | log.AllEvents = []*proto.ConversationEvent{ |
| 42 | { |
| 43 | ConversationId: srcCID, |
| 44 | Seq: 1, |
| 45 | Messages: []*proto.Message{ |
| 46 | {Role: "user", Content: &proto.Content{Type: &proto.Content_Text{Text: &proto.TextContent{Text: "msg 1"}}}}, |
| 47 | }, |
| 48 | State: proto.State_STATE_COMPLETED, |
| 49 | }, |
| 50 | } |
| 51 | |
| 52 | c, err := controller.New(ctx, controller.Config{ |
| 53 | EventLogBuilder: func() (executor.EventLog, error) { |
| 54 | return log, nil |
| 55 | }, |
| 56 | PlannerBuilder: func(ctx context.Context, r *controller.Registry) (agent.Agent, error) { |
| 57 | return &dummyAgent{}, nil |
| 58 | }, |
| 59 | }) |
| 60 | if err != nil { |
| 61 | t.Fatal(err) |
| 62 | } |
| 63 | defer c.Close() |
| 64 | |
| 65 | s := New(c) |
| 66 | |
| 67 | resp, err := s.ForkConversation(ctx, &proto.ForkConversationRequest{ |
| 68 | SrcConversationId: srcCID, |
| 69 | DestConversationId: destCID, |
| 70 | }) |
| 71 | if err != nil { |
| 72 | t.Fatal(err) |
| 73 | } |
| 74 | |
| 75 | if resp.ConversationId != destCID { |
| 76 | t.Fatalf("expected destCID %s, got %s", destCID, resp.ConversationId) |
| 77 | } |
| 78 | |
| 79 | events, err := log.Events(ctx, destCID) |
| 80 | if err != nil { |
| 81 | t.Fatal(err) |
| 82 | } |
| 83 | if len(events) != 1 { |
| 84 | t.Fatalf("expected 1 event, got %d", len(events)) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // TestServer_Fork_RequiresDestID verifies that ForkConversation rejects |
| 89 | // a request without DestConversationId. The substrate router relies on |
nothing calls this directly
no test coverage detected