-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnozzle_plugin_test.go
65 lines (52 loc) · 1.8 KB
/
nozzle_plugin_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
package main_test
import (
"strings"
"github.com/cloudfoundry/cli/plugin/fakes"
io_helpers "github.com/cloudfoundry/cli/testhelpers/io"
. "github.com/jtuchscherer/nozzle-plugin"
"github.com/jtuchscherer/nozzle-plugin/testhelpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
const (
ACCESS_TOKEN = "access_token"
)
var _ = Describe("NozzlePlugin", func() {
Describe(".Run", func() {
var fakeCliConnection *fakes.FakeCliConnection
var nozzlerCmd *NozzlerCmd
var fakeFirehose *testhelpers.FakeFirehose
BeforeEach(func() {
fakeFirehose = testhelpers.NewFakeFirehose(ACCESS_TOKEN)
fakeFirehose.SendLog("Log Message")
fakeFirehose.Start()
fakeCliConnection = &fakes.FakeCliConnection{}
fakeCliConnection.AccessTokenReturns(ACCESS_TOKEN, nil)
fakeCliConnection.DopplerEndpointReturns(fakeFirehose.URL(), nil)
nozzlerCmd = &NozzlerCmd{}
})
AfterEach(func() {
fakeFirehose.Close()
})
It("works", func(done Done) {
defer close(done)
outputChan := make(chan []string)
go func() {
output := io_helpers.CaptureOutput(func() {
nozzlerCmd.Run(fakeCliConnection, []string{"nozzle", "--debug"})
})
outputChan <- output
}()
var output []string
Eventually(outputChan, 2).Should(Receive(&output))
outputString := strings.Join(output, "|")
Expect(outputString).To(ContainSubstring("What type of firehose messages do you want to see?"))
Expect(outputString).To(ContainSubstring("Starting the nozzle"))
Expect(outputString).To(ContainSubstring("Hit Cmd+c to exit"))
Expect(outputString).To(ContainSubstring("websocket: close 1000"))
Expect(outputString).To(ContainSubstring("Log Message"))
Expect(outputString).To(ContainSubstring("WEBSOCKET REQUEST"))
Expect(outputString).To(ContainSubstring("WEBSOCKET RESPONSE"))
}, 3)
})
})