本文整理匯總了Golang中net/http/httptest.Server.Unmarshal方法的典型用法代碼示例。如果您正苦於以下問題:Golang Server.Unmarshal方法的具體用法?Golang Server.Unmarshal怎麽用?Golang Server.Unmarshal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/http/httptest.Server
的用法示例。
在下文中一共展示了Server.Unmarshal方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
mockController.fetchFileIdCh <- 0
mockController.fetchFileErrCh <- broker.NewFetchFileError("some-error", "")
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