forked from bakape/thumbnailer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ffmpeg_test.go
63 lines (55 loc) · 1021 Bytes
/
ffmpeg_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package thumbnailer
import (
"strings"
"testing"
)
func TestDims(t *testing.T) {
t.Parallel()
type testCase struct {
name string
dims Dims
}
var cases []testCase
var c testCase
for _, f := range samples {
if ignore[f] {
continue
}
c.name = f
switch {
case f == "with_cover.mp3":
c.dims = Dims{1280, 720}
case f == "sample.gif":
c.dims = Dims{584, 720}
case strings.HasPrefix(f, "no_cover"),
strings.HasPrefix(f, "with_cover"):
c.dims = Dims{0, 0}
case strings.HasPrefix(f, "sample"):
c.dims = Dims{1280, 720}
default:
continue
}
cases = append(cases, c)
}
opts := Options{
ThumbDims: Dims{150, 150},
}
for i := range cases {
c := cases[i]
t.Run(c.name, func(t *testing.T) {
t.Parallel()
f := openSample(t, c.name)
defer f.Close()
src, _, err := Process(f, opts)
switch err {
case nil:
case ErrCantThumbnail:
default:
t.Fatal(err)
}
if src.Dims != c.dims {
t.Fatalf("%v != %v", src.Dims, c.dims)
}
})
}
}