Merge pull request #55 from r3b-fish/feature/exclude-empty-hls-key-info-file-param

Skip an empty -hls_key_info_file parameter
This commit is contained in:
Fran
2020-06-24 16:55:40 +02:00
committed by GitHub
3 changed files with 30 additions and 4 deletions
+4 -3
View File
@@ -3,7 +3,7 @@ jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.11
- image: circleci/golang:1.14-buster
environment:
GO111MODULE: "on"
@@ -12,5 +12,6 @@ jobs:
- checkout
# specify any bash command here prefixed with `run: `
- run: go mod vendor
- run: go test -v ./tests/...
- run: sudo apt-get update && sudo apt-get install ffmpeg
- run: go mod download
- run: go test -failfast -v -run=. ./...
+5 -1
View File
@@ -1158,7 +1158,11 @@ func (m *Mediafile) ObtainMapMetadata() []string {
}
func (m *Mediafile) ObtainEncryptionKey() []string {
return []string{"-hls_key_info_file", m.encryptionKey}
if m.encryptionKey != "" {
return []string{"-hls_key_info_file", m.encryptionKey}
}
return nil
}
func (m *Mediafile) ObtainBframe() []string {
+21
View File
@@ -0,0 +1,21 @@
package models
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestMedia(t *testing.T) {
t.Run("#ObtainEncryptionKey", func(t *testing.T) {
t.Run("Should get nil if encryptionKey is not set", func(t *testing.T) {
mediaFile := Mediafile{}
require.Nil(t, mediaFile.ObtainEncryptionKey())
})
t.Run("Should return file.keyinfo if it's set", func(t *testing.T) {
mediaFile := Mediafile{encryptionKey: "file.keyinfo"}
require.Equal(t, []string{"-hls_key_info_file", "file.keyinfo"}, mediaFile.ObtainEncryptionKey())
})
})
}