fix: update watchlist service tests
This commit is contained in:
@@ -123,10 +123,10 @@ func (h *Handler) HandleWatchPage(w http.ResponseWriter, r *http.Request) {
|
||||
for i := start; i <= maxCount; i++ {
|
||||
epStr := strconv.Itoa(i)
|
||||
meta, err := h.svc.GetEpisodeMetadata(r.Context(), id, epStr)
|
||||
|
||||
|
||||
title := fmt.Sprintf("Episode %d", i)
|
||||
imgURL := ""
|
||||
|
||||
|
||||
if err == nil && meta != nil {
|
||||
if info, ok := meta["episodeInfo"].(map[string]any); ok {
|
||||
if thumbs, ok := info["thumbnails"].([]any); ok && len(thumbs) > 0 {
|
||||
|
||||
@@ -35,14 +35,14 @@ type SkipSegment struct {
|
||||
}
|
||||
|
||||
type WatchPageData struct {
|
||||
MalID int
|
||||
Title string
|
||||
CurrentEpisode string
|
||||
StartTimeSeconds float64
|
||||
CurrentStatus string
|
||||
InitialMode string
|
||||
AvailableModes []string
|
||||
ModeSources map[string]ModeSource
|
||||
Segments []SkipSegment
|
||||
FallbackEpisodes map[string]int
|
||||
MalID int
|
||||
Title string
|
||||
CurrentEpisode string
|
||||
StartTimeSeconds float64
|
||||
CurrentStatus string
|
||||
InitialMode string
|
||||
AvailableModes []string
|
||||
ModeSources map[string]ModeSource
|
||||
Segments []SkipSegment
|
||||
FallbackEpisodes map[string]int
|
||||
}
|
||||
|
||||
@@ -32,12 +32,9 @@ func TestAddEntry_RejectsInvalidAnimeID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
q := &fakeQuerier{}
|
||||
svc := NewService(q, nil)
|
||||
svc := NewService(q, nil, nil)
|
||||
|
||||
err := svc.AddEntry(context.Background(), "user-1", AddRequest{
|
||||
AnimeID: 0,
|
||||
Status: "watching",
|
||||
})
|
||||
err := svc.AddToWatchlist(context.Background(), "user-1", 0, "watching")
|
||||
|
||||
if err != ErrInvalidAnimeID {
|
||||
t.Fatalf("expected ErrInvalidAnimeID, got %v", err)
|
||||
@@ -52,12 +49,9 @@ func TestAddEntry_RejectsInvalidStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
q := &fakeQuerier{}
|
||||
svc := NewService(q, nil)
|
||||
svc := NewService(q, nil, nil)
|
||||
|
||||
err := svc.AddEntry(context.Background(), "user-1", AddRequest{
|
||||
AnimeID: 1,
|
||||
Status: "invalid",
|
||||
})
|
||||
err := svc.AddToWatchlist(context.Background(), "user-1", 1, "invalid")
|
||||
|
||||
if err != ErrInvalidStatus {
|
||||
t.Fatalf("expected ErrInvalidStatus, got %v", err)
|
||||
|
||||
Reference in New Issue
Block a user