test: add forced source refresh and manifest cache integration tests
This commit is contained in:
@@ -10,7 +10,8 @@ import (
|
||||
)
|
||||
|
||||
type rewritePlaybackService struct {
|
||||
targets []string
|
||||
targets []string
|
||||
targetURL string
|
||||
}
|
||||
|
||||
func (s *rewritePlaybackService) BuildWatchData(context.Context, int, []string, string, string, string) (domain.WatchPageData, error) {
|
||||
@@ -31,7 +32,7 @@ func (s *rewritePlaybackService) SignProxyToken(targetURL, _ string, _ string) (
|
||||
}
|
||||
|
||||
func (s *rewritePlaybackService) ResolveProxyToken(string, string) (string, string, error) {
|
||||
return "", "", nil
|
||||
return s.targetURL, "", nil
|
||||
}
|
||||
|
||||
func (s *rewritePlaybackService) UpsertSkipSegmentOverride(context.Context, string, int64, int, string, float64, float64) error {
|
||||
|
||||
@@ -17,14 +17,39 @@ import (
|
||||
type watchPagePlaybackService struct {
|
||||
domain.PlaybackService
|
||||
|
||||
data domain.WatchPageData
|
||||
err error
|
||||
data domain.WatchPageData
|
||||
err error
|
||||
refreshRequested bool
|
||||
}
|
||||
|
||||
func (s *watchPagePlaybackService) BuildWatchData(context.Context, int, []string, string, string, string) (domain.WatchPageData, error) {
|
||||
func (s *watchPagePlaybackService) BuildWatchData(ctx context.Context, _ int, _ []string, _ string, _ string, _ string) (domain.WatchPageData, error) {
|
||||
s.refreshRequested = domain.PlaybackSourceRefreshRequested(ctx)
|
||||
return s.data, s.err
|
||||
}
|
||||
|
||||
func TestHandleEpisodeDataRequestsForcedSourceRefresh(t *testing.T) {
|
||||
data := baseWatchPageData()
|
||||
data.WatchData.ModeSources = map[string]domain.ModeSource{
|
||||
"sub": {Token: "opaque", Type: "m3u8"},
|
||||
}
|
||||
svc := &watchPagePlaybackService{data: data}
|
||||
h := &PlaybackHandler{svc: svc}
|
||||
gin.SetMode(gin.TestMode)
|
||||
router := gin.New()
|
||||
router.GET("/api/watch/episode/:animeId/:episode", h.HandleEpisodeData)
|
||||
|
||||
req := httptest.NewRequestWithContext(context.Background(), http.MethodGet, "/api/watch/episode/123/1?mode=sub&refresh=1", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
|
||||
}
|
||||
if !svc.refreshRequested {
|
||||
t.Fatal("episode handler did not request a forced source refresh")
|
||||
}
|
||||
}
|
||||
|
||||
type watchPageAnimeService struct {
|
||||
domain.AnimePlaybackService
|
||||
t *testing.T
|
||||
|
||||
Reference in New Issue
Block a user