-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_test.go
More file actions
56 lines (45 loc) · 999 Bytes
/
Copy pathbash_test.go
File metadata and controls
56 lines (45 loc) · 999 Bytes
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
package sprocess_test
import (
"bytes"
. "github.com/hyperboloide/sprocess"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Bash", func() {
testBin := genBlob(1 << 22)
It("should Encode", func() {
out1 := new(bytes.Buffer)
data := NewData()
zip := &Bash{"gzip", "zip"}
Ω(zip.Start()).To(BeNil())
Ω(zip.Encode(
bytes.NewReader(testBin),
out1,
data)).To(BeNil())
Ω(bytes.Equal(out1.Bytes(), testBin)).To(BeFalse())
out2 := new(bytes.Buffer)
unzip := &Bash{
Cmd: "gzip -d",
Name: "unzip",
}
Ω(unzip.Start()).To(BeNil())
Ω(unzip.Encode(
bytes.NewReader(out1.Bytes()),
out2,
data)).To(BeNil())
Ω(bytes.Equal(out2.Bytes(), testBin)).To(BeTrue())
})
It("should crash", func() {
out1 := new(bytes.Buffer)
data := NewData()
crash := &Bash{
Cmd: "exit 1",
Name: "crash",
}
Ω(crash.Start()).To(BeNil())
Ω(crash.Encode(
bytes.NewReader(testBin),
out1,
data)).ToNot(BeNil())
})
})