-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmock_test.go
36 lines (27 loc) · 1021 Bytes
/
mock_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
package gobmock
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Mock", func() {
It("includes the stub function", func() {
mock := Mock("jimjam", "").MockContents()
Expect(mock).To(ContainSubstring("jimjam() {"))
})
It("includes the pipe handling", func() {
mock := Mock("helicopter", "").MockContents()
Expect(mock).To(ContainSubstring("while read -r -t0.1; do"))
})
It("includes the custom mock script", func() {
mock := Mock("visitor", "cakes and coffee").MockContents()
Expect(mock).To(ContainSubstring("cakes and coffee"))
})
It("can conditionally call through", func() {
mock := MockOrCallThrough("printf", "echo 'starships in bottles'", "[ $1 == 'monkey' ]")
Expect(mock.MockContents()).To(ContainSubstring("monkey"))
})
It("should not include pipe handling when WithoutReading is used", func() {
mock := Mock("1coordinates0", "").WithoutReading().MockContents()
Expect(mock).NotTo(ContainSubstring("while read -r -t0.1; do"))
})
})