Esempio n. 1
0
func TestAbly(t *testing.T) {
	t.Parallel()
	RegisterFailHandler(Fail)
	RunSpecs(t, "Ably Suite")
}

var (
	testApp *testutil.Sandbox
	client  *ably.RestClient
	channel *ably.RestChannel
)

var _ = BeforeSuite(func() {
	app, err := testutil.NewSandbox(nil)
	Expect(err).NotTo(HaveOccurred())
	testApp = app
})

var _ = BeforeEach(func() {
	cl, err := ably.NewRestClient(testApp.Options(nil))
	Expect(err).NotTo(HaveOccurred())
	client = cl
	channel = client.Channel("test")
})

var _ = AfterSuite(func() {
	err := testApp.Close()
	Expect(err).NotTo(HaveOccurred())
})
Esempio n. 2
0
			}))

		})

		Context("with JSON encoding set up", func() {
			BeforeEach(func() {
				options := &ably.ClientOptions{
					NoTLS:      true,
					Protocol:   ably.ProtocolJSON,
					HTTPClient: newHTTPClientMock(server),
				}

				client, err = ably.NewRestClient(testApp.Options(options))
				Expect(err).NotTo(HaveOccurred())

				err := client.Channel("test").Publish("ping", "pong")
				Expect(err).NotTo(HaveOccurred())
			})

			It("encode the body of the message in JSON", func() {
				var anyJson []map[string]interface{}
				err := json.Unmarshal(buffer, &anyJson)
				Expect(err).NotTo(HaveOccurred())
			})
		})

		Context("with msgpack encoding set up", func() {
			BeforeEach(func() {
				options := &ably.ClientOptions{
					NoTLS:      true,
					Protocol:   ably.ProtocolMsgPack,