-
Notifications
You must be signed in to change notification settings - Fork 11
/
binwrapper_test.go
94 lines (84 loc) · 2.08 KB
/
binwrapper_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package binwrapper_test
import (
"github.com/nickalie/go-binwrapper"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
//Example of wrapping cwebp command line tool
func ExampleNewBinWrapper() {
base := "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/"
bin := binwrapper.NewBinWrapper().
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-mac-10.12.tar.gz").
Os("darwin")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-linux-x86-32.tar.gz").
Os("linux").
Arch("x86")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-linux-x86-64.tar.gz").
Os("linux").
Arch("x64")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-windows-x64.zip").
Os("win32").
Arch("x64").
ExecPath("cwebp.exe")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-windows-x86.zip").
Os("win32").
Arch("x86").
ExecPath("cwebp.exe")).
Strip(2).
Dest("vendor/cwebp").
ExecPath("cwebp")
err := bin.Run("-version")
fmt.Printf("stdout: %s\n", string(bin.StdOut()))
fmt.Printf("stderr: %s\n", string(bin.StdErr()))
fmt.Printf("err: %v\n", err)
}
func TestNewBinWrapperNoError(t *testing.T) {
base := "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/"
bin := binwrapper.NewBinWrapper().
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-mac-10.12.tar.gz").
Os("darwin")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-linux-x86-32.tar.gz").
Os("linux").
Arch("x86")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-linux-x86-64.tar.gz").
Os("linux").
Arch("x64")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-windows-x64.zip").
Os("win32").
Arch("x64")).
Src(
binwrapper.NewSrc().
URL(base + "libwebp-0.6.0-windows-x86.zip").
Os("win32").
Arch("x86")).
Strip(2).
Dest("vendor/cwebp").
ExecPath("cwebp").AutoExe()
err := bin.Run("-version")
assert.Nil(t, err)
}
func TestNewBinWrapperError(t *testing.T) {
bin := binwrapper.NewBinWrapper().
ExecPath("cwebp")
err := bin.Run("-version")
assert.NotNil(t, err)
}