Goose 00036 is a renumbered copy of the vault tables. Degraded read stays off by default and only runs after authorization; tombstones and unpublished artifacts fail closed. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package artifactvault
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestIngestIdempotentAndRejectsNonTerminal(t *testing.T) {
|
|
ctx := context.Background()
|
|
ing := &Ingest{Env: "dev", Reg: NewMemoryRegistry()}
|
|
now := time.Now().UTC()
|
|
payload := []byte("# committed body")
|
|
if err := ing.AgentCommit(ctx, 9, "doc_a", "ev-1", 4, payload); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := ing.AgentCommit(ctx, 9, "doc_a", "ev-1", 4, payload); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if ing.Reg.Coverage(ctx).Required != 1 {
|
|
t.Fatalf("idempotent ingest required=%d", ing.Reg.Coverage(ctx).Required)
|
|
}
|
|
if err := ing.AssistantReply(ctx, 9, "msg:1", "s:t", 1, "run", "none", &now, []byte("hello world from assistant")); err == nil {
|
|
t.Fatal("none policy must reject")
|
|
}
|
|
}
|
|
|
|
func TestCoverageGateFailClosed(t *testing.T) {
|
|
if CoveragePASS(Coverage{}) {
|
|
t.Fatal("empty coverage must fail")
|
|
}
|
|
if err := PreflightDestroy(Coverage{Required: 2, Verified: 1}, true, true, true); err == nil {
|
|
t.Fatal("incomplete coverage must fail destroy")
|
|
}
|
|
}
|