Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 19, 2024
1 parent 789e370 commit 9e2dffe
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/typing/converters/string_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,36 @@ func TestDecimalConverter_Convert(t *testing.T) {
}
}
}

func TestStructConverter_Convert(t *testing.T) {
{
// Toast
val, err := StructConverter{}.Convert(constants.ToastUnavailableValuePlaceholder)
assert.NoError(t, err)
assert.Equal(t, `{"key":"__debezium_unavailable_value"}`, val)
}
{
// Toast object
val, err := StructConverter{}.Convert(`{"__debezium_unavailable_value":"__debezium_unavailable_value"}`)
assert.NoError(t, err)
assert.Equal(t, `{"key":"__debezium_unavailable_value"}`, val)
}
{
// Normal string
val, err := StructConverter{}.Convert(`{"foo":"bar"}`)
assert.NoError(t, err)
assert.Equal(t, `{"foo":"bar"}`, val)
}
{
// Boolean
val, err := StructConverter{}.Convert(true)
assert.NoError(t, err)
assert.Equal(t, "true", val)
}
{
// Map
val, err := StructConverter{}.Convert(map[string]any{"foo": "bar"})
assert.NoError(t, err)
assert.Equal(t, `{"foo":"bar"}`, val)
}
}

0 comments on commit 9e2dffe

Please sign in to comment.