summaryrefslogtreecommitdiff
path: root/internal/api/handlers_more_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-07 00:05:40 +0300
committerPaul Buetow <paul@buetow.org>2026-05-07 00:05:40 +0300
commit8db759e3f7be6ddbbc1738d285eef565b24d94bc (patch)
tree5d7392eddf48fb6db258309217e8191e5929d619 /internal/api/handlers_more_test.go
parent973c3108b71063ea932aed6c67e16e393b5e6c41 (diff)
Handle share page marshal errors (a1)
Diffstat (limited to 'internal/api/handlers_more_test.go')
-rw-r--r--internal/api/handlers_more_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/api/handlers_more_test.go b/internal/api/handlers_more_test.go
index 2675483..4e698b8 100644
--- a/internal/api/handlers_more_test.go
+++ b/internal/api/handlers_more_test.go
@@ -1084,6 +1084,28 @@ func TestServer_SharePage(t *testing.T) {
})
}
+func TestInjectShareMedia(t *testing.T) {
+ t.Run("injects marshaled metadata", func(t *testing.T) {
+ html, err := injectShareMedia(`<script><!--SHARE_MEDIA--></script>`, map[string]string{"stream_url": "/s/abc/stream"})
+ if err != nil {
+ t.Fatalf("expected no error, got %v", err)
+ }
+ if !strings.Contains(html, `"stream_url":"/s/abc/stream"`) {
+ t.Fatalf("expected injected JSON, got %q", html)
+ }
+ })
+
+ t.Run("returns marshal error", func(t *testing.T) {
+ _, err := injectShareMedia(`<script><!--SHARE_MEDIA--></script>`, map[string]any{"bad": make(chan int)})
+ if err == nil {
+ t.Fatal("expected marshal error")
+ }
+ if !strings.Contains(err.Error(), "marshal share metadata") {
+ t.Fatalf("expected wrapped marshal error, got %v", err)
+ }
+ })
+}
+
func TestServer_ShareStream(t *testing.T) {
path := makeTempFile(t, "shared")
cfg := &internal.Config{SessionTimeoutHours: 24}