Skip to content

Commit

Permalink
Verify manifest contents parsed in unit test (#1349)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh1 authored Jul 29, 2024
1 parent 25f3c33 commit e21d85a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions clients/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ index_1.m3u8`
const validMediaManifest = `#EXTM3U
#EXT-X-VERSION:3
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.4160000000,
#EXT-X-TARGETDURATION:11
#EXTINF:10.416,
0.ts
#EXTINF:5.3340000000,
#EXTINF:5.334,
5000.ts
#EXT-X-ENDLIST`
#EXT-X-ENDLIST
`

func DownloadRetryBackoffFailInstantly() backoff.BackOff {
return backoff.WithMaxRetries(backoff.NewConstantBackOff(0*time.Second), 0)
Expand All @@ -51,6 +52,7 @@ func TestDownloadRenditionManifestFailsWhenItCantParseTheManifest(t *testing.T)
defer func() { DownloadRetryBackoff = DownloadRetryBackoffLong }()
manifestFile, err := os.CreateTemp(os.TempDir(), "manifest-*.m3u8")
require.NoError(t, err)
defer os.Remove(manifestFile.Name())
_, err = manifestFile.WriteString("This isn't a manifest!")
require.NoError(t, err)

Expand All @@ -62,6 +64,7 @@ func TestDownloadRenditionManifestFailsWhenItCantParseTheManifest(t *testing.T)
func TestDownloadRenditionManifestFailsWhenItReceivesAMasterManifest(t *testing.T) {
manifestFile, err := os.CreateTemp(os.TempDir(), "manifest-*.m3u8")
require.NoError(t, err)
defer os.Remove(manifestFile.Name())
_, err = manifestFile.WriteString(validMasterManifest)
require.NoError(t, err)

Expand All @@ -73,11 +76,13 @@ func TestDownloadRenditionManifestFailsWhenItReceivesAMasterManifest(t *testing.
func TestItCanDownloadAValidRenditionManifest(t *testing.T) {
manifestFile, err := os.CreateTemp(os.TempDir(), "manifest-*.m3u8")
require.NoError(t, err)
defer os.Remove(manifestFile.Name())
_, err = manifestFile.WriteString(validMediaManifest)
require.NoError(t, err)

_, err = DownloadRenditionManifest("blah", manifestFile.Name())
manifest, err := DownloadRenditionManifest("blah", manifestFile.Name())
require.NoError(t, err)
require.Equal(t, validMediaManifest, manifest.String())
}

func TestItCanConvertRelativeURLsToOSURLs(t *testing.T) {
Expand Down

0 comments on commit e21d85a

Please sign in to comment.