From 03ef43c44b4a1a777dcc1e5b52fc617b2c686c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 21 Nov 2024 13:32:05 +0100 Subject: [PATCH] Add test --- replication/event_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/replication/event_test.go b/replication/event_test.go index 1333cd5ef..7dacb2539 100644 --- a/replication/event_test.go +++ b/replication/event_test.go @@ -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) + } +}