Analysis stays read-only, and a revoked project member cannot confirm an old proposal. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package coordinator
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/intent"
|
|
)
|
|
|
|
type fakeImpact struct {
|
|
writes int
|
|
}
|
|
|
|
func (f *fakeImpact) AnalyzeImpact(context.Context, int64, int64, string) (string, error) {
|
|
return "只读", nil
|
|
}
|
|
|
|
func (f *fakeImpact) ProposeRevision(context.Context, int64, int64, string, bool) (string, error) {
|
|
f.writes++
|
|
return "proposal-1-by-4", nil
|
|
}
|
|
|
|
func TestRevisePropose_RevokedAccessDoesNotWrite(t *testing.T) {
|
|
impact := &fakeImpact{}
|
|
engine := &CoordinatorEngine{impact: impact}
|
|
engine.SetProjectAccess(func(context.Context, int64, int64) error {
|
|
return errors.New("revoked")
|
|
})
|
|
res, err := engine.handleRevisePropose(t.Context(), &intent.CandidateIntent{Intent: intent.IntentRevisePropose}, &UserProjectContext{
|
|
User: UserInfo{ID: "4"},
|
|
Project: ProjectInfo{ID: "9"},
|
|
}, "确认修订提案")
|
|
if err == nil || res == nil || res.Status != StatusRejected || impact.writes != 0 {
|
|
t.Fatalf("res %+v err %v writes %d", res, err, impact.writes)
|
|
}
|
|
}
|