mirror of
https://github.com/alfg/ffmpegd.git
synced 2025-09-26 19:41:15 +08:00
tests: setting up tests and Github tests workflow.
This commit is contained in:
28
.github/workflows/go.yml
vendored
Normal file
28
.github/workflows/go.yml
vendored
Normal file
@@ -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 ./...
|
@@ -100,9 +100,13 @@ go build -v
|
||||
./ffmpegd
|
||||
```
|
||||
|
||||
#### Tests
|
||||
```
|
||||
go test ./...
|
||||
```
|
||||
|
||||
## TODO
|
||||
* Logging levels and output
|
||||
* Tests
|
||||
|
||||
## License
|
||||
MIT
|
||||
|
24
ffmpeg/ffmpeg_test.go
Normal file
24
ffmpeg/ffmpeg_test.go
Normal file
@@ -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
ffmpeg/ffprobe_test.go
Normal file
29
ffmpeg/ffprobe_test.go
Normal file
@@ -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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user