Document and verify optional CMS associations
verify / verify (push) Successful in 4m50s

This commit is contained in:
2026-09-10 18:00:25 -04:00
parent fcb200453a
commit ebcbbf06f5
5 changed files with 57 additions and 0 deletions
+14
View File
@@ -24,6 +24,20 @@ func TestAssociationsBoundsAndIdentity(t *testing.T) {
}
}
}
func TestAssociationsAreOptional(t *testing.T) {
for _, source := range []Reference{{Kind: "news", ID: "article"}, {Kind: "project", ID: "project"}, {Kind: "policy", ID: "terms"}} {
for _, raw := range []string{`{}`, `{"terms":null,"links":null}`, `{"terms":[],"links":[]}`, `{"terms":["go"]}`, `{"links":[{"kind":"project","id":"other"}]}`} {
var value Associations
if err := json.Unmarshal([]byte(raw), &value); err != nil {
t.Fatal(err)
}
if err := value.Validate(source); err != nil {
t.Fatalf("optional associations rejected: %s: %v", raw, err)
}
}
}
}
func TestTaxonomyAndTermText(t *testing.T) {
tax := Taxonomy{ID: "categories", Slug: "categories", Name: "Categories", Revision: 1, Active: true}
if tax.Validate() != nil {