/
ssht_test.go
69 lines (64 loc) · 1.84 KB
/
ssht_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
package ssht_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/xchapter7x/ssht"
)
var _ = Describe("ssht", func() {
Describe("given we have a ssht server", func() {
Context("when created", func() {
var startServer = func() bool {
ssh := &ssht.SSHTestServer{
AllowPasswordAuthN: false,
Username: "joe",
Password: "user",
AllowKeyAuthN: true,
FakeResponseBytes: []byte(`this is a test`),
SSHCommandMatch: "ls -lha",
}
ssh.Start()
return true
}
It("then it should start safely", func() {
Ω(func() { startServer() }).ShouldNot(Panic())
})
It("then it should not block", func() {
Eventually(startServer).Should(BeTrue())
})
})
Context("when we call close on it", func() {
var err error
var ssh *ssht.SSHTestServer
BeforeEach(func() {
ssh = &ssht.SSHTestServer{
AllowPasswordAuthN: false,
Username: "joe",
Password: "user",
AllowKeyAuthN: true,
FakeResponseBytes: []byte(`this is a test`),
SSHCommandMatch: "ls -lha",
}
err = ssh.Start()
})
It("then it should close the ssh test server", func() {
Ω(err).ShouldNot(HaveOccurred())
Ω(ssh.Close()).ShouldNot(HaveOccurred())
Ω(ssh.Connected).Should(BeFalse())
})
})
XDescribe("given a WhenCalledWith Method", func() {
Context("when called with a command string", func() {
It("then it should allow us to fake the output from the given command", func() {
Ω(true).Should(BeFalse())
})
})
})
XDescribe("given a CommandCallCount Method", func() {
Context("when called with a command string", func() {
It("then it should allow to see a count of the number of times the given command was called", func() {
Ω(true).Should(BeFalse())
})
})
})
})
})