コード例 #1
0
ファイル: broker_test.go プロジェクト: jmptrader/talaria
			fetchFile := buildFetchFile(99, "some-file")
			data, err := proto.Marshal(fetchFile)
			Expect(err).ToNot(HaveOccurred())

			conn.WriteMessage(websocket.BinaryMessage, data)

			Eventually(mockController.fetchFileCh).Should(Receive(Equal("some-file")))

			_, data, err = conn.ReadMessage()
			Expect(err).ToNot(HaveOccurred())

			server := &messages.Server{}
			err = server.Unmarshal(data)
			Expect(err).ToNot(HaveOccurred())
			Expect(server.GetMessageId()).To(BeEquivalentTo(99))
			Expect(server.GetMessageType()).To(Equal(messages.Server_Error))
			Expect(server.Error).ToNot(BeNil())
			Expect(server.FileLocation).To(BeNil())
			Expect(server.Error.GetMessage()).To(Equal("some-error"))
		})

		It("reports the file ID", func(done Done) {
			defer close(done)
			conn, _, err := websocket.DefaultDialer.Dial(wsUrl, nil)
			Expect(err).ToNot(HaveOccurred())

			mockController.fetchFileIdCh <- 8
			mockController.fetchFileErrCh <- nil

			fetchFile := buildFetchFile(99, "some-file")
			data, err := proto.Marshal(fetchFile)