Part of archie-core-1786637490069-11-e245c170 (memory engine contract and owning registry), under epic archie-core-1786637499161 (pluggable memory engine). Stands up internal/domain/memory as a conforming engine family per the strict plugin engine rule, mirroring internal/domain/curator's split exactly as that issue's notes specify: - contract.go: MemoryEngine (Lifecycle + Store + identity + Bind), with Store carrying the real domain operations the epic requires -- Write/Query/List/Forget -- not just Name/Version. Store is split out from MemoryEngine so the interface stays under golangci-lint's interfacebloat threshold the same way curator's embedded Lifecycle does: an embedded interface counts as one slot, not its expanded method count. - registrar.go: narrow typed host access (EventSink, Clock). No capability-gated fields yet -- unlike curator's Tools/Skills, no memory-specific host service exists to gate on today, so Registry.Bind passes the host straight through rather than filtering. - registry.go: Register/Get/Names/Start/Health/Stop with the same duplicate/nil/panic/failure-isolation guarantees as curator's registry, ctx-bounded Stop, reverse-order shutdown. This is the contract only -- no engine implements it yet, and internal/memory's existing ad-hoc MemoryProvider/Manager (pre-migration) is untouched, per the issue's explicit "do not extend in place" note.
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package memory
|
|
|
|
import "testing"
|
|
|
|
func TestObservationValidateRequiresIdentityAndContent(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
obs Observation
|
|
wantErr bool
|
|
}{
|
|
{"empty identity", Observation{Content: "x"}, true},
|
|
{"empty content", Observation{Identity: "u1"}, true},
|
|
{"both empty", Observation{}, true},
|
|
{"valid", Observation{Identity: "u1", Content: "x"}, false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
err := tt.obs.Validate()
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("Validate() = %v, wantErr %v", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestQueryValidateRequiresIdentity(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if err := (Query{}).Validate(); err == nil {
|
|
t.Fatal("Validate() = nil for empty identity, want error")
|
|
}
|
|
if err := (Query{Identity: "u1"}).Validate(); err != nil {
|
|
t.Fatalf("Validate() = %v for identity-only query, want nil (Text may be empty)", err)
|
|
}
|
|
}
|
|
|
|
func TestManifestValidateAcceptsZeroValue(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if err := (Manifest{}).Validate(); err != nil {
|
|
t.Fatalf("Validate() = %v, want nil: no field is required yet", err)
|
|
}
|
|
}
|