A community based topic aggregation platform built on atproto
1package tests
2
3import (
4 "testing"
5
6 lexicon "github.com/bluesky-social/indigo/atproto/lexicon"
7)
8
9func TestLexiconSchemaValidation(t *testing.T) {
10 // Create a new catalog
11 catalog := lexicon.NewBaseCatalog()
12
13 // Load all schemas from the lexicon directory
14 schemaPath := "../internal/atproto/lexicon"
15 if err := catalog.LoadDirectory(schemaPath); err != nil {
16 t.Fatalf("Failed to load lexicon schemas: %v", err)
17 }
18
19 // Test that we can resolve our key schemas
20 expectedSchemas := []string{
21 "social.coves.actor.profile",
22 "social.coves.actor.subscription",
23 "social.coves.actor.membership",
24 "social.coves.community.profile",
25 "social.coves.community.rules",
26 "social.coves.community.wiki",
27 "social.coves.post.text",
28 "social.coves.post.image",
29 "social.coves.post.video",
30 "social.coves.post.article",
31 "social.coves.richtext.markup",
32 "social.coves.richtext.mention",
33 "social.coves.richtext.link",
34 "social.coves.embed.image",
35 "social.coves.embed.video",
36 "social.coves.embed.external",
37 "social.coves.embed.post",
38 "social.coves.interaction.vote",
39 "social.coves.interaction.tag",
40 "social.coves.interaction.comment",
41 "social.coves.interaction.share",
42 "social.coves.moderation.vote",
43 "social.coves.moderation.tribunalVote",
44 "social.coves.moderation.ruleProposal",
45 }
46
47 for _, schemaID := range expectedSchemas {
48 t.Run(schemaID, func(t *testing.T) {
49 if _, err := catalog.Resolve(schemaID); err != nil {
50 t.Errorf("Failed to resolve schema %s: %v", schemaID, err)
51 }
52 })
53 }
54}
55
56func TestLexiconCrossReferences(t *testing.T) {
57 // Create a new catalog
58 catalog := lexicon.NewBaseCatalog()
59
60 // Load all schemas
61 if err := catalog.LoadDirectory("../internal/atproto/lexicon"); err != nil {
62 t.Fatalf("Failed to load lexicon schemas: %v", err)
63 }
64
65 // Test specific cross-references that should work
66 crossRefs := map[string]string{
67 "social.coves.richtext.markup#byteSlice": "byteSlice definition in markup schema",
68 "social.coves.actor.profile#geoLocation": "geoLocation definition in actor profile",
69 "social.coves.community.rules#rule": "rule definition in community rules",
70 }
71
72 for ref, description := range crossRefs {
73 t.Run(ref, func(t *testing.T) {
74 if _, err := catalog.Resolve(ref); err != nil {
75 t.Errorf("Failed to resolve cross-reference %s (%s): %v", ref, description, err)
76 }
77 })
78 }
79}