MCPcopy
hub / github.com/dropbox/godropbox / TestBasic

Method TestBasic

database/binlog/table_map_event_test.go:18–65  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

16var _ = Suite(&TableMapEventSuite{})
17
18func (s *TableMapEventSuite) TestBasic(c *C) {
19 s.WriteEvent(
20 mysql_proto.LogEventType_TABLE_MAP_EVENT,
21 uint16(0),
22 []byte{
23 // table id
24 76, 0, 0, 0, 0, 0,
25 // flags
26 1, 0,
27 // db name length
28 8,
29 // db name
30 115, 104, 97, 114, 100, 55, 54, 55, 0,
31 // table name length
32 30,
33 // table name
34 99, 97, 109, 101, 114, 97, 95, 117, 112, 108,
35 111, 97, 100, 95, 105, 110, 100, 101, 120, 95,
36 115, 117, 109, 109, 97, 114, 121, 95, 118, 51, 0,
37 // number of columns
38 2,
39 3, 2,
40 // metadata size
41 0,
42 // null bits
43 2})
44
45 event, err := s.NextEvent()
46 c.Assert(err, IsNil)
47
48 c.Assert(event, NotNil)
49 tm, ok := event.(*TableMapEvent)
50 c.Assert(ok, IsTrue)
51 c.Check(tm.TableId(), Equals, uint64(76))
52 c.Check(tm.TableFlags(), Equals, uint16(1))
53 c.Check(string(tm.DatabaseName()), Equals, "shard767")
54 c.Check(string(tm.TableName()), Equals, "camera_upload_index_summary_v3")
55 c.Check(tm.ColumnTypesBytes(), DeepEquals, []byte{3, 2})
56 c.Check(tm.MetadataBytes(), DeepEquals, []byte{})
57 c.Check(tm.NullColumnsBytes(), DeepEquals, []byte{2})
58
59 descriptors := tm.ColumnDescriptors()
60 c.Assert(len(descriptors), Equals, 2)
61 c.Check(descriptors[0].Type(), Equals, mysql_proto.FieldType_LONG)
62 c.Check(descriptors[0].IsNullable(), IsFalse)
63 c.Check(descriptors[1].Type(), Equals, mysql_proto.FieldType_SHORT)
64 c.Check(descriptors[1].IsNullable(), IsTrue)
65}
66
67func (s *TableMapEventSuite) TestTableWithMetadata(c *C) {
68 s.WriteEvent(

Callers

nothing calls this directly

Calls 13

ColumnTypesBytesMethod · 0.80
MetadataBytesMethod · 0.80
NullColumnsBytesMethod · 0.80
NextEventMethod · 0.65
TableIdMethod · 0.65
TableFlagsMethod · 0.65
DatabaseNameMethod · 0.65
TableNameMethod · 0.65
ColumnDescriptorsMethod · 0.65
TypeMethod · 0.65
IsNullableMethod · 0.65
WriteEventMethod · 0.45

Tested by

no test coverage detected