diff --git a/.circleci/config.yml b/.circleci/config.yml index 39b9cf0..0c5b444 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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/... \ No newline at end of file + - run: sudo apt-get update && sudo apt-get install ffmpeg + - run: go mod download + - run: go test -failfast -v -run=. ./... diff --git a/models/media.go b/models/media.go index d1b1ec1..0edea4f 100644 --- a/models/media.go +++ b/models/media.go @@ -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 { diff --git a/models/media_test.go b/models/media_test.go new file mode 100644 index 0000000..ce613b4 --- /dev/null +++ b/models/media_test.go @@ -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()) + }) + }) +}