tinyrelayfile
tinyrelay/tinyclient/room_parity_test.go/

tinyclient/room_parity_test.go raw
1package tinyclient
2
3import (
4 "encoding/json"
5 "os"
6 "testing"
7)
8
9func TestRoomParityFixture(t *testing.T) {
10 data, err := os.ReadFile("room_parity.json")
11 if err != nil {
12 t.Fatal(err)
13 }
14 var cases []struct {
15 Name string `json:"name"`
16 Content string `json:"content"`
17 Tags [][]string `json:"tags"`
18 Attachments []string `json:"attachments"`
19 Text string `json:"text"`
20 }
21 if err := json.Unmarshal(data, &cases); err != nil {
22 t.Fatal(err)
23 }
24 for _, tc := range cases {
25 t.Run(tc.Name, func(t *testing.T) {
26 row := map[string]any{"content": tc.Content, "tags": tc.Tags}
27 items := roomAttachments(row)
28 if len(items) != len(tc.Attachments) {
29 t.Fatalf("attachments: got %d, want %d", len(items), len(tc.Attachments))
30 }
31 for i, want := range tc.Attachments {
32 if items[i].URL != want {
33 t.Errorf("attachment %d: got %q, want %q", i, items[i].URL, want)
34 }
35 }
36 rendered := string(renderChatMarkdown(tc.Content))
37 if tc.Text != "" && rendered == "" {
38 t.Fatal("markdown renderer returned empty output")
39 }
40 })
41 }
42}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs