mirror of
https://github.com/xfrr/goffmpeg.git
synced 2026-04-22 23:17:21 +08:00
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:
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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())
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user