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

Method TestDeleteRowsV2

database/binlog/rows_event_test.go:438–495  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

436}
437
438func (s *RowsEventSuite) TestDeleteRowsV2(c *C) {
439 s.WriteEvent(
440 mysql_proto.LogEventType_DELETE_ROWS_EVENT,
441 uint16(0),
442 []byte{
443 // table id
444 testRowsTableId, 0, 0, 0, 0, 0,
445 // table flags,
446 14, 0,
447 // extra metadata (total) length + 2
448 7, 0,
449 0, // RW_V_EXTRAINFO_TAG
450 3, // info blob length
451 'f', 'o', 'o',
452 // # known columns
453 5,
454 // used column bits
455 (1 + 2 + 8 + 16), // skipping the int24 column
456
457 // ROW DATA:
458
459 // Row 1: tiny = 1; short = 2; long = 4; longlong = 8
460 0, // null column bits
461 1, // tiny
462 2, 0, // short
463 4, 0, 0, 0, // long
464 8, 0, 0, 0, 0, 0, 0, 0, // longlong
465 })
466
467 event, err := s.NextEvent()
468 c.Log(err)
469 c.Assert(err, IsNil)
470
471 w, ok := event.(*DeleteRowsEvent)
472 c.Assert(ok, IsTrue)
473
474 c.Assert(w.Version(), Equals, mysql_proto.RowsEventVersion_V2)
475 c.Check(w.TableId(), Equals, uint64(testRowsTableId))
476 c.Check(w.RowsFlags(), Equals, uint16(14))
477 c.Check(w.NumColumns(), Equals, 5)
478 c.Check(w.ExtraRowInfoBytes(), DeepEquals, []byte("foo"))
479
480 descriptors := s.context.ColumnDescriptors()
481 expectedUsed := []ColumnDescriptor{
482 descriptors[0],
483 descriptors[1],
484 descriptors[3],
485 descriptors[4],
486 }
487
488 c.Check(w.UsedColumns(), DeepEquals, expectedUsed)
489
490 rows := w.DeletedRows()
491 c.Assert(len(rows), Equals, 1)
492
493 expectedRow1 := RowValues{uint64(1), uint64(2), uint64(4), uint64(8)}
494 c.Check(rows[0], DeepEquals, expectedRow1)
495}

Callers

nothing calls this directly

Calls 11

RowsFlagsMethod · 0.80
ExtraRowInfoBytesMethod · 0.80
DeletedRowsMethod · 0.80
NextEventMethod · 0.65
VersionMethod · 0.65
TableIdMethod · 0.65
NumColumnsMethod · 0.65
ColumnDescriptorsMethod · 0.65
WriteEventMethod · 0.45
CheckMethod · 0.45
UsedColumnsMethod · 0.45

Tested by

no test coverage detected