add TestRunOnDemand

This commit is contained in:
aler9 2020-07-30 13:41:56 +02:00
parent 00a2de1daa
commit 7ec3f771d1
2 changed files with 27 additions and 2 deletions

View File

@ -32,7 +32,7 @@ format:
define DOCKERFILE_TEST
FROM amd64/$(BASE_IMAGE)
RUN apk add --no-cache make docker-cli git
RUN apk add --no-cache make docker-cli git ffmpeg
WORKDIR /s
COPY go.mod go.sum ./
RUN go mod download

View File

@ -352,7 +352,8 @@ func TestProxy(t *testing.T) {
"paths:\n" +
" proxied:\n" +
" source: rtsp://testuser:testpass@localhost:8554/teststream\n" +
" sourceProtocol: " + proto + "\n")
" sourceProtocol: " + proto + "\n" +
" sourceOnDemand: yes\n")
p2, err := newProgram([]string{"stdin"}, bytes.NewBuffer(stdin))
require.NoError(t, err)
defer p2.close()
@ -374,3 +375,27 @@ func TestProxy(t *testing.T) {
})
}
}
func TestRunOnDemand(t *testing.T) {
stdin := []byte("\n" +
"paths:\n" +
" ondemand:\n" +
" runOnDemand: ffmpeg -hide_banner -loglevel error -re -i test-images/ffmpeg/emptyvideo.ts -c copy -f rtsp rtsp://localhost:8554/ondemand\n")
p1, err := newProgram([]string{"stdin"}, bytes.NewBuffer(stdin))
require.NoError(t, err)
defer p1.close()
time.Sleep(1 * time.Second)
cnt1, err := newContainer("ffmpeg", "dest", []string{
"-i", "rtsp://" + ownDockerIp + ":8554/ondemand",
"-vframes", "1",
"-f", "image2",
"-y", "/dev/null",
})
require.NoError(t, err)
defer cnt1.close()
code := cnt1.wait()
require.Equal(t, 0, code)
}