Skip to content

Commit

Permalink
tests: setting up tests and Github tests workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
alfg committed Mar 21, 2021
1 parent 907e320 commit 538168f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: Install ffmpeg
run: sudo apt-get install ffmpeg

- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ go build -v
./ffmpegd
```

#### Tests
```
go test ./...
```

## TODO
* Logging levels and output
* Tests

## License
MIT
24 changes: 24 additions & 0 deletions ffmpeg/ffmpeg_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ffmpeg

import (
"testing"
)

const testFile = "../demo/tears-of-steel-5s.mp4"
const testPayload = "{\"format\":{\"container\":\"mp4\",\"clip\":false},\"video\":{\"codec\":\"libx264\",\"preset\":\"none\",\"pass\":\"1\",\"crf\":23,\"pixel_format\":\"auto\",\"frame_rate\":\"auto\",\"speed\":\"auto\",\"tune\":\"none\",\"profile\":\"none\",\"level\":\"none\",\"faststart\":false,\"size\":\"source\",\"width\":\"1080\",\"height\":\"1920\",\"format\":\"widescreen\",\"aspect\":\"auto\",\"scaling\":\"auto\",\"codec_options\":\"\"},\"audio\":{\"codec\":\"copy\",\"channel\":\"source\",\"quality\":\"auto\",\"sampleRate\":\"auto\",\"volume\":\"100\"},\"filter\":{\"deband\":false,\"deshake\":false,\"deflicker\":false,\"dejudder\":false,\"denoise\":\"none\",\"deinterlace\":\"none\",\"brightness\":\"0\",\"contrast\":\"1\",\"saturation\":\"0\",\"gamma\":\"0\",\"acontrast\":\"33\"}}"

func TestFFmpegRun(t *testing.T) {
f := &FFmpeg{}
err := f.Run(testFile, "out.mp4", testPayload)
if err != nil {
t.Error(err)
}
}

func TestFFmpegRunFail(t *testing.T) {
f := &FFmpeg{}
err := f.Run(testFile, "out.mp4", "{}") // Bad payload.
if err == nil {
t.Error()
}
}
29 changes: 29 additions & 0 deletions ffmpeg/ffprobe_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ffmpeg

import (
"testing"
)

func TestFFProbeRun(t *testing.T) {
ffprobe := &FFProbe{}
probe, err := ffprobe.Run(testFile)
if err != nil {
t.Error(err)
}

if len(probe.Streams) != 2 {
t.Error()
}

if probe.Streams[0].Index != 0 {
t.Error()
}

if probe.Streams[0].Width != 1280 {
t.Error()
}

if probe.Streams[0].Height != 534 {
t.Error()
}
}

0 comments on commit 538168f

Please # to comment.