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.facet",
32 "social.coves.embed.image",
33 "social.coves.embed.video",
34 "social.coves.embed.external",
35 "social.coves.embed.post",
36 "social.coves.interaction.vote",
37 "social.coves.interaction.tag",
38 "social.coves.interaction.comment",
39 "social.coves.interaction.share",
40 "social.coves.moderation.vote",
41 "social.coves.moderation.tribunalVote",
42 "social.coves.moderation.ruleProposal",
43 }
44
45 for _, schemaID := range expectedSchemas {
46 t.Run(schemaID, func(t *testing.T) {
47 if _, err := catalog.Resolve(schemaID); err != nil {
48 t.Errorf("Failed to resolve schema %s: %v", schemaID, err)
49 }
50 })
51 }
52}
53
54func TestLexiconCrossReferences(t *testing.T) {
55 // Create a new catalog
56 catalog := lexicon.NewBaseCatalog()
57
58 // Load all schemas
59 if err := catalog.LoadDirectory("../internal/atproto/lexicon"); err != nil {
60 t.Fatalf("Failed to load lexicon schemas: %v", err)
61 }
62
63 // Test specific cross-references that should work
64 crossRefs := map[string]string{
65 "social.coves.richtext.facet#byteSlice": "byteSlice definition in facet schema",
66 "social.coves.actor.profile#geoLocation": "geoLocation definition in actor profile",
67 "social.coves.community.rules#rule": "rule definition in community rules",
68 }
69
70 for ref, description := range crossRefs {
71 t.Run(ref, func(t *testing.T) {
72 if _, err := catalog.Resolve(ref); err != nil {
73 t.Errorf("Failed to resolve cross-reference %s (%s): %v", ref, description, err)
74 }
75 })
76 }
77}