From 6b505bd36819df47fb407988d4ef7e4e8b33be55 Mon Sep 17 00:00:00 2001 From: Nathan <148575555+nathan-artie@users.noreply.github.com> Date: Wed, 12 Jun 2024 23:31:00 -0700 Subject: [PATCH] Add test --- clients/bigquery/cast_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/clients/bigquery/cast_test.go b/clients/bigquery/cast_test.go index def9f639f..b894d8231 100644 --- a/clients/bigquery/cast_test.go +++ b/clients/bigquery/cast_test.go @@ -3,6 +3,7 @@ package bigquery import ( "fmt" "math/big" + "testing" "time" "github.com/artie-labs/transfer/lib/ptr" @@ -160,3 +161,24 @@ func (b *BigQueryTestSuite) TestCastColVal() { assert.Nil(b.T(), colVal) } } + +func TestEncodeStructToJSONString(t *testing.T) { + { + // Empty string: + result, err := EncodeStructToJSONString("") + assert.NoError(t, err) + assert.Equal(t, "", result) + } + { + // Toasted string: + result, err := EncodeStructToJSONString("__debezium_unavailable_value") + assert.NoError(t, err) + assert.Equal(t, `{"key":"__debezium_unavailable_value"}`, result) + } + { + // Map: + result, err := EncodeStructToJSONString(map[string]any{"foo": "bar", "baz": 1234}) + assert.NoError(t, err) + assert.Equal(t, `{"baz":1234,"foo":"bar"}`, result) + } +}