Files
Agent-System/internal/docrevision/invalid_docid_test.go
T
weichenandCursor 7f8331f893 fix(docrevision): harden empty docID, per-doc auth, and failed-save honesty
Stage generation without a real document must not panic or enter the ledger.
Unknown orphan IDs are denied, write paths check author/lease/lifecycle, PATCH
no longer returns a fake 200, and overlay matching survives client/server block id drift.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 09:02:54 +00:00

30 lines
862 B
Go

package docrevision_test
import (
"context"
"errors"
"testing"
"chat-agent-system/internal/docrevision"
)
func TestGetRevisionState_EmptyDocID(t *testing.T) {
svc := docrevision.NewService(nil)
_, err := svc.GetRevisionState(context.Background(), "")
if !errors.Is(err, docrevision.ErrInvalidDocID) {
t.Fatalf("empty docID want ErrInvalidDocID, got %v", err)
}
_, err = svc.GetRevisionState(context.Background(), " ")
if !errors.Is(err, docrevision.ErrInvalidDocID) {
t.Fatalf("blank docID want ErrInvalidDocID, got %v", err)
}
}
func TestCommitAgentVersion_EmptyDocID(t *testing.T) {
svc := docrevision.NewService(nil)
_, err := svc.CommitAgentVersion(context.Background(), "", 1, docrevision.CommitAgentDecision{Decision: "commit"})
if !errors.Is(err, docrevision.ErrInvalidDocID) {
t.Fatalf("want ErrInvalidDocID, got %v", err)
}
}