Implement projections and operations

This commit is contained in:
kami
2026-07-26 19:14:46 +04:00
parent 9937cd5cd0
commit 8822e028bb
6 changed files with 148 additions and 7 deletions
+18
View File
@@ -0,0 +1,18 @@
package operations
import (
"encoding/json"
"orchestra/internal/domain"
"testing"
"time"
)
func TestBuildBrief(t *testing.T) {
now := time.Now()
p, _ := json.Marshal(map[string]any{"harness_id": "cc", "consumed": 12})
es := []domain.Event{{Type: "TaskCompleted", At: now}, {Type: "TaskFailed", At: now}, {Type: "ApprovalRequested", At: now}, {Type: "QuotaReported", At: now, Payload: p}}
b := BuildBrief(es, now.Add(-time.Minute), now.Add(time.Minute), GitSync{Status: "clean"})
if b.Completed != 1 || b.Failed != 1 || len(b.NeedsAttention) != 2 || b.Quota["cc"] != 12 {
t.Fatalf("unexpected brief: %+v", b)
}
}