-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner_test.go
33 lines (29 loc) · 1.04 KB
/
runner_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package spireav_test
import (
"context"
"testing"
"github.com/spiretechnology/spireav"
"github.com/stretchr/testify/require"
)
func overrideFfmpegPath(path string) func() {
original := spireav.FfmpegPath
spireav.FfmpegPath = path
return func() {
spireav.FfmpegPath = original
}
}
func TestRunnerErrors(t *testing.T) {
t.Run("invalid args", func(t *testing.T) {
runner := spireav.NewRunner(spireav.RunnableArgs{"several", "bad", "args"})
err := runner.Run(context.Background())
require.Error(t, err, "expected error when running process with invalid args")
require.ErrorContains(t, err, "Invalid argument")
})
t.Run("ffmpeg not in path", func(t *testing.T) {
defer overrideFfmpegPath("something-that-does-not-exist")()
runner := spireav.NewRunner(spireav.RunnableArgs{"-i", "something"})
err := runner.Run(context.Background())
require.Error(t, err, "expected error when path is missing ffmpeg binary")
require.ErrorContains(t, err, "starting ffmpeg process: exec: \"something-that-does-not-exist\": executable file not found")
})
}