Skip to content

Commit

Permalink
chore(hls): remove unused test
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness4 committed Aug 19, 2024
1 parent 7e87735 commit 4ccb5c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 46 deletions.
30 changes: 0 additions & 30 deletions hls/hls_downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,36 +185,6 @@ loop:
suite.Equal(combinedExpectedURLs, urls)
}

func (suite *DownloaderTestSuite) TestFillQueueAtCheckpoint() {
// Arrange
urls := make([]string, 0, 11)
urlsChan := make(chan string)
ctx, cancel := context.WithCancel(context.Background())
errChan := make(chan error, 1)

// Act
go func() {
err := suite.impl.fillQueue(ctx, urlsChan)
errChan <- err
}()

loop:
for {
select {
case url := <-urlsChan:
urls = append(urls, url)
case <-time.After(5 * time.Second):
cancel()
break loop
}
}

// Assert
err := <-errChan
suite.Error(context.Canceled, err)
suite.Equal(combinedExpectedURLs[len(combinedExpectedURLs)-1:], urls)
}

func (suite *DownloaderTestSuite) AfterTest(_, _ string) {
suite.server.Close()
}
Expand Down
27 changes: 11 additions & 16 deletions withny/api/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
Expand Down Expand Up @@ -127,16 +126,15 @@ streamLoop:
for _, constraint := range constraints {
width, height := parseResolution(stream.Resolution)
switch {
case constraint.MinBandwidth > 0 && stream.Bandwidth <= constraint.MinBandwidth,
constraint.MaxBandwidth > 0 && stream.Bandwidth >= constraint.MaxBandwidth,
constraint.MinHeight > 0 && int64(height) <= constraint.MinHeight,
constraint.MaxHeight > 0 && int64(height) >= constraint.MaxHeight,
constraint.MinWidth > 0 && int64(width) <= constraint.MinWidth,
constraint.MaxWidth > 0 && int64(width) >= constraint.MaxWidth,
constraint.MinFrameRate > 0 && stream.FrameRate <= constraint.MinFrameRate,
constraint.MaxFrameRate > 0 && stream.FrameRate >= constraint.MaxFrameRate,
case constraint.MinBandwidth > 0 && stream.Bandwidth < constraint.MinBandwidth,
constraint.MaxBandwidth > 0 && stream.Bandwidth > constraint.MaxBandwidth,
constraint.MinHeight > 0 && int64(height) < constraint.MinHeight,
constraint.MaxHeight > 0 && int64(height) > constraint.MaxHeight,
constraint.MinWidth > 0 && int64(width) < constraint.MinWidth,
constraint.MaxWidth > 0 && int64(width) > constraint.MaxWidth,
constraint.MinFrameRate > 0 && stream.FrameRate < constraint.MinFrameRate,
constraint.MaxFrameRate > 0 && stream.FrameRate > constraint.MaxFrameRate,
constraint.AudioOnly && stream.Video != "audio_only":
fmt.Println(stream.Video)
continue streamLoop
}
}
Expand All @@ -150,12 +148,9 @@ streamLoop:
}

func parseResolution(resolution string) (width, height int) {
res := strings.Split(resolution, "x")
if len(res) != 2 {
return 0, 0
}
width, _ = strconv.Atoi(res[0])
height, _ = strconv.Atoi(res[1])
w, h, _ := strings.Cut(resolution, "x")
width, _ = strconv.Atoi(w)
height, _ = strconv.Atoi(h)
return width, height
}

Expand Down

0 comments on commit 4ccb5c7

Please sign in to comment.