mirror of
https://github.com/bluenviron/mediamtx
synced 2024-12-13 18:24:58 +00:00
add TestRunOnDemand
This commit is contained in:
parent
00a2de1daa
commit
7ec3f771d1
2
Makefile
2
Makefile
@ -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
|
||||
|
27
main_test.go
27
main_test.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user