Wrote write goroutine functions.

Refactored subpackages back to root package.
This commit is contained in:
Jay
2026-03-04 18:33:42 -05:00
parent f88982a0b7
commit 894eab5405
17 changed files with 450 additions and 217 deletions

44
schema_test.go Normal file
View File

@@ -0,0 +1,44 @@
package heartwood
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestNewRelationshipWithValidation(t *testing.T) {
cases := []struct {
name string
start *Node
end *Node
wantPanic bool
wantPanicText string
}{
{
name: "valid start and end nodes",
start: NewUserNode("pubkey1"),
end: NewEventNode("abc123"),
},
{
name: "mismatched start node label",
start: NewEventNode("abc123"),
end: NewEventNode("abc123"),
wantPanic: true,
wantPanicText: "expected start node to have label \"User\". got [Event]",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if tc.wantPanic {
assert.PanicsWithError(t, tc.wantPanicText, func() {
NewSignedRel(tc.start, tc.end, nil)
})
return
}
rel := NewSignedRel(tc.start, tc.end, nil)
assert.Equal(t, "SIGNED", rel.Type)
assert.Contains(t, rel.Start.Labels.ToArray(), "User")
assert.Contains(t, rel.End.Labels.ToArray(), "Event")
})
}
}