Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Apr 11, 2024
1 parent 5e7b475 commit 8e03168
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions lib/cdc/util/relational_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package util

import (
"encoding/json"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -134,25 +133,37 @@ func TestGetData_TestDelete(t *testing.T) {
IdempotentKey: "updated_at",
}

kvMap := map[string]any{"pk": 1004}
var schemaEventPayload SchemaEventPayload
assert.NoError(t, json.Unmarshal([]byte(PostgresDelete), &schemaEventPayload))

assert.True(t, schemaEventPayload.DeletePayload())
data := schemaEventPayload.GetData(kvMap, tc)
fmt.Println("data", data)

expectedKeyValues := map[string]any{
"id": 1004,
"first_name": "Anne",
"last_name": "Kretchmar",
"email": "annek@noanswer.org",
}

for expectedKey, expectedValue := range expectedKeyValues {
value, isOk := data[expectedKey]
assert.True(t, isOk)
assert.Equal(t, expectedValue, value)
kvMap := map[string]any{"pk": 1004}
{
// Postgres
var schemaEventPayload SchemaEventPayload
assert.NoError(t, json.Unmarshal([]byte(PostgresDelete), &schemaEventPayload))
assert.True(t, schemaEventPayload.DeletePayload())
data := schemaEventPayload.GetData(kvMap, tc)
for expectedKey, expectedValue := range expectedKeyValues {
value, isOk := data[expectedKey]
assert.True(t, isOk)
assert.Equal(t, expectedValue, value)
}
}
{
// MySQL
var schemaEventPayload SchemaEventPayload
assert.NoError(t, json.Unmarshal([]byte(MySQLDelete), &schemaEventPayload))
assert.True(t, schemaEventPayload.DeletePayload())
data := schemaEventPayload.GetData(kvMap, tc)
for expectedKey, expectedValue := range expectedKeyValues {
value, isOk := data[expectedKey]
assert.True(t, isOk)
assert.Equal(t, expectedValue, value)
}
}
}

Expand Down

0 comments on commit 8e03168

Please sign in to comment.