- ControlPlane 라우터에 워커/에이전트 구독 채널을 추가한다 - ProtoSocket 기반 실시간 양방향 채널( dispatcher, envelope, server)을 구현한다 - Forgejo push 이벤트를 provider 어댑터로 처리하도록 연동한다 - PostgreSQL 스토리지 백엔드를 분리하여 postgres.go로 신설한다 - Git engine command에 diff/checkout/merge 연쇄 연산을 추가한다 - 런타임 모델에 agentSession, runtimeChannel 스키마를 추가한다 - 데이터베이스 마이그레이션에 agent_session, runtime_channel, lease 테이블을 추가한다 - agent-contract에 Forgejo branch events 계약 문서를 작성한다 - 로드맵 마일스톤과 아카이브 작업을 갱신한다
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package protosocket
|
|
|
|
import "testing"
|
|
|
|
func TestEventSubscriptionAllowsMatchingBranchEvent(t *testing.T) {
|
|
subscription := EventSubscription{
|
|
Events: []string{"branch.updated"},
|
|
RepoID: "nomadcode",
|
|
Branch: "develop",
|
|
}
|
|
event := NewEventEnvelope("branch.updated", map[string]any{
|
|
"type": "branch.updated",
|
|
"repo_id": "nomadcode",
|
|
"branch": "develop",
|
|
})
|
|
|
|
if !subscription.Allows(event) {
|
|
t.Fatal("expected matching branch event to be allowed")
|
|
}
|
|
}
|
|
|
|
func TestEventSubscriptionRejectsDifferentBranch(t *testing.T) {
|
|
subscription := EventSubscription{
|
|
Events: []string{"branch.updated"},
|
|
RepoID: "nomadcode",
|
|
Branch: "develop",
|
|
}
|
|
event := NewEventEnvelope("branch.updated", map[string]any{
|
|
"type": "branch.updated",
|
|
"repo_id": "nomadcode",
|
|
"branch": "feature/a",
|
|
})
|
|
|
|
if subscription.Allows(event) {
|
|
t.Fatal("expected different branch event to be rejected")
|
|
}
|
|
}
|
|
|
|
func TestEventSubscriptionRejectsDifferentEvent(t *testing.T) {
|
|
subscription := EventSubscription{
|
|
Events: []string{"branch.updated"},
|
|
RepoID: "nomadcode",
|
|
}
|
|
event := NewEventEnvelope("operation.completed", map[string]any{
|
|
"type": "operation.completed",
|
|
"repo_id": "nomadcode",
|
|
})
|
|
|
|
if subscription.Allows(event) {
|
|
t.Fatal("expected different event action to be rejected")
|
|
}
|
|
}
|
|
|
|
func TestEventSubscriptionWildcardAllowsAnyEventForRepo(t *testing.T) {
|
|
subscription := EventSubscription{
|
|
Events: []string{"*"},
|
|
RepoID: "nomadcode",
|
|
}
|
|
event := NewEventEnvelope("operation.completed", map[string]any{
|
|
"type": "operation.completed",
|
|
"repo_id": "nomadcode",
|
|
})
|
|
|
|
if !subscription.Allows(event) {
|
|
t.Fatal("expected wildcard event subscription to allow matching repo")
|
|
}
|
|
}
|