Exemplo n.º 1
0
func testStreamTablesPanics(t *testing.T, bpc binlogplayer.BinlogPlayerClient) {
	c := make(chan *proto.BinlogTransaction)
	bpr := bpc.StreamTables(testTablesRequest, c)
	if se, ok := <-c; ok {
		t.Fatalf("got a response when error expected: %v", se)
	}
	err := bpr.Error()
	if err == nil || !strings.Contains(err.Error(), "test-triggered panic") {
		t.Errorf("wrong error from panic: %v", err)
	}
}
Exemplo n.º 2
0
// Run runs the test suite
func Run(t *testing.T, bpc binlogplayer.BinlogPlayerClient, addr string, fake *FakeBinlogStreamer) {
	if err := bpc.Dial(addr, 30*time.Second); err != nil {
		t.Fatalf("Dial failed: %v", err)
	}

	// no panic
	testStreamKeyRange(t, bpc)
	testStreamTables(t, bpc)

	// panic now, and test
	fake.panics = true
	testStreamKeyRangePanics(t, bpc)
	testStreamTablesPanics(t, bpc)
}
Exemplo n.º 3
0
func testStreamKeyRange(t *testing.T, bpc binlogplayer.BinlogPlayerClient) {
	c := make(chan *proto.BinlogTransaction)
	bpr := bpc.StreamKeyRange(testKeyRangeRequest, c)
	if se, ok := <-c; !ok {
		t.Fatalf("got no response")
	} else {
		if !reflect.DeepEqual(*se, *testBinlogTransaction) {
			t.Errorf("got wrong result, got %v expected %v", *se, *testBinlogTransaction)
		}
	}
	if se, ok := <-c; ok {
		t.Fatalf("got a response when error expected: %v", se)
	}
	if err := bpr.Error(); err != nil {
		t.Errorf("got unexpected error: %v", err)
	}
}