Skip to content

Commit

Permalink
add TestRunOnDemand
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jul 30, 2020
1 parent 00a2de1 commit 7ec3f77
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 26 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}

0 comments on commit 7ec3f77

Please sign in to comment.