From ac1a4bc16c7bec7fa79b2e75b5483488c20155b0 Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Thu, 21 Mar 2024 12:31:40 -0700 Subject: [PATCH] Move Bitcoinity websocket capture, and test it. --- example.json => bitcoinity/captured.json | 0 bitcoinity/model_test.go | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+) rename example.json => bitcoinity/captured.json (100%) diff --git a/example.json b/bitcoinity/captured.json similarity index 100% rename from example.json rename to bitcoinity/captured.json diff --git a/bitcoinity/model_test.go b/bitcoinity/model_test.go index 441d41d..6225f73 100644 --- a/bitcoinity/model_test.go +++ b/bitcoinity/model_test.go @@ -21,3 +21,24 @@ func TestUnmarshalGetTickerResponse(t *testing.T) { //go:embed get_ticker.json var getTickerJson []byte + +func TestUnmarshalWebhookMessages(t *testing.T) { + var msgs []bitcoinity.Message + err := json.Unmarshal(capturedJson, &msgs) + if err != nil { + t.Errorf("failed to unmarshal webhook messages JSON: %v", err) + } + for _, msg := range msgs { + if msg.Event != "new_msg" { + continue + } + var payload bitcoinity.MarketPayload + err := json.Unmarshal(msg.Payload, &payload) + if err != nil { + t.Errorf("failed to unmarshal market payload JSON: %v", err) + } + } +} + +//go:embed captured.json +var capturedJson []byte