Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dveeden committed Nov 21, 2024
1 parent b2d723a commit 03ef43c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions replication/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,22 @@ func TestIntVarEvent(t *testing.T) {
require.Equal(t, INSERT_ID, ev.Type)
require.Equal(t, uint64(23), ev.Value)
}

func TestDecodeSid(t *testing.T) {
testcases := []struct {
input []byte
gtidFormat GtidFormat
uuidCount uint64
}{
{[]byte{1, 2, 0, 0, 0, 0, 0, 1}, GtidFormatTagged, 2},
{[]byte{1, 1, 0, 0, 0, 0, 0, 1}, GtidFormatTagged, 1},
{[]byte{1, 0, 0, 0, 0, 0, 0, 1}, GtidFormatTagged, 0},
{[]byte{1, 0, 0, 0, 0, 0, 0, 0}, GtidFormatClassic, 1},
}

for _, tc := range testcases {
format, uuidCount := decodeSid(tc.input)
assert.Equal(t, tc.gtidFormat, format)
assert.Equal(t, tc.uuidCount, uuidCount)
}
}

0 comments on commit 03ef43c

Please sign in to comment.