You've already forked agentic-coding-workflow
主流程
This commit is contained in:
@@ -40,16 +40,17 @@ func (r *convFakeRepo) InsertConversation(_ context.Context, p InsertConversatio
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
c := &Conversation{
|
||||
ID: p.ID,
|
||||
UserID: p.UserID,
|
||||
ProjectID: p.ProjectID,
|
||||
WorkspaceID: p.WorkspaceID,
|
||||
IssueID: p.IssueID,
|
||||
ModelID: p.ModelID,
|
||||
SystemPrompt: p.SystemPrompt,
|
||||
Title: p.Title,
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
ID: p.ID,
|
||||
UserID: p.UserID,
|
||||
ProjectID: p.ProjectID,
|
||||
WorkspaceID: p.WorkspaceID,
|
||||
IssueID: p.IssueID,
|
||||
RequirementID: p.RequirementID,
|
||||
ModelID: p.ModelID,
|
||||
SystemPrompt: p.SystemPrompt,
|
||||
Title: p.Title,
|
||||
CreatedAt: time.Now(),
|
||||
UpdatedAt: time.Now(),
|
||||
}
|
||||
r.conversations[p.ID] = c
|
||||
return c, nil
|
||||
@@ -70,9 +71,13 @@ func (r *convFakeRepo) ListConversationsByUser(_ context.Context, userID uuid.UU
|
||||
defer r.mu.Unlock()
|
||||
var out []Conversation
|
||||
for _, c := range r.conversations {
|
||||
if c.UserID == userID && c.DeletedAt == nil {
|
||||
out = append(out, *c)
|
||||
if c.UserID != userID || c.DeletedAt != nil {
|
||||
continue
|
||||
}
|
||||
if f.RequirementID != nil && (c.RequirementID == nil || *c.RequirementID != *f.RequirementID) {
|
||||
continue
|
||||
}
|
||||
out = append(out, *c)
|
||||
}
|
||||
limit := f.Limit
|
||||
if limit > 0 && len(out) > limit {
|
||||
@@ -235,6 +240,33 @@ func TestConversationService_Create_HappyPath(t *testing.T) {
|
||||
assert.Equal(t, &userID, entry.UserID)
|
||||
}
|
||||
|
||||
func TestConversationService_Create_WithRequirementMount(t *testing.T) {
|
||||
repo := newConvFakeRepo()
|
||||
svc := newConvSvc(repo, noopAuditor{})
|
||||
userID := uuid.Must(uuid.NewV7())
|
||||
m := addModel(repo, true)
|
||||
|
||||
reqID := uuid.Must(uuid.NewV7())
|
||||
projID := uuid.Must(uuid.NewV7())
|
||||
c, err := svc.Create(context.Background(), userID, CreateConversationInput{
|
||||
ModelID: m.ID, ProjectID: &projID, RequirementID: &reqID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, c.RequirementID)
|
||||
assert.Equal(t, reqID, *c.RequirementID)
|
||||
|
||||
// List 按 requirement 过滤:命中 1 条;其他 requirement 不命中。
|
||||
_, err = svc.Create(context.Background(), userID, CreateConversationInput{ModelID: m.ID})
|
||||
require.NoError(t, err)
|
||||
list, err := svc.List(context.Background(), userID, ConversationFilter{RequirementID: &reqID})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, list, 1)
|
||||
other := uuid.Must(uuid.NewV7())
|
||||
list, err = svc.List(context.Background(), userID, ConversationFilter{RequirementID: &other})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, list)
|
||||
}
|
||||
|
||||
func TestConversationService_Create_WithSystemTemplate(t *testing.T) {
|
||||
repo := newConvFakeRepo()
|
||||
svc := newConvSvc(repo, noopAuditor{})
|
||||
|
||||
Reference in New Issue
Block a user