diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-30 12:45:18 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-30 12:45:18 +0300 |
| commit | 54bc9013aa0463962a1cfd67fa278de3d401d85a (patch) | |
| tree | 526c719285a6153fdc82f8a7feb7b4ef98c1ce78 /internal/service/no_rows_test.go | |
| parent | 38e318e71d50e4340ddbf1ae63b3d85e958b4644 (diff) | |
ja: implement public share landing page and improve error mapping
- Add web/share.html with a minimal HTML5 video player, theme variables,
centered layout, play overlay, and Back to Home link.
- Update handleSharePage to return HTML for browser Accept headers
(text/html or empty) and JSON for application/json. Return 410 Gone
for expired shares.
- Update handleShareStream to map service errors to distinct HTTP codes:
ErrShareExpired -> 410, ErrShareNotFound/ErrMediaNotFound -> 404.
- Improve ValidateShareToken and StreamSharedMedia to return sentinel
errors (ErrShareNotFound, ErrShareExpired, ErrMediaNotFound) instead
of generic string errors.
- Update and add tests for share page HTML/JSON negotiation and share
stream 404/410 responses.
Diffstat (limited to 'internal/service/no_rows_test.go')
| -rw-r--r-- | internal/service/no_rows_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/service/no_rows_test.go b/internal/service/no_rows_test.go index 3606b63..9200668 100644 --- a/internal/service/no_rows_test.go +++ b/internal/service/no_rows_test.go @@ -135,8 +135,8 @@ func TestService_NoRows_ReturnsNil(t *testing.T) { } svc := NewMediaService(store, newMockClock(), "/tmp/media") sh, err := svc.ValidateShareToken(ctx, "nope") - if err != nil { - t.Fatalf("expected no error, got %v", err) + if !errors.Is(err, ErrShareNotFound) { + t.Fatalf("expected ErrShareNotFound, got %v", err) } if sh != nil { t.Fatalf("expected nil share, got %+v", sh) @@ -153,8 +153,8 @@ func TestService_NoRows_ReturnsNil(t *testing.T) { } svc := NewMediaService(store, newMockClock(), "/tmp/media") _, err := svc.StreamSharedMedia(ctx, "nope") - if err == nil { - t.Fatal("expected error for missing share") + if !errors.Is(err, ErrShareNotFound) { + t.Fatalf("expected ErrShareNotFound, got %v", err) } }) |
