(t *testing.T)
| 523 | } |
| 524 | |
| 525 | func TestBuildTableSampleQueries(t *testing.T) { |
| 526 | db, mock, err := sqlmock.New() |
| 527 | require.NoError(t, err) |
| 528 | defer func() { |
| 529 | require.NoError(t, db.Close()) |
| 530 | }() |
| 531 | |
| 532 | conn, err := db.Conn(context.Background()) |
| 533 | require.NoError(t, err) |
| 534 | baseConn := newBaseConn(conn, true, nil) |
| 535 | tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel() |
| 536 | metrics := newMetrics(promutil.NewDefaultFactory(), nil) |
| 537 | |
| 538 | d := &Dumper{ |
| 539 | tctx: tctx, |
| 540 | conf: DefaultConfig(), |
| 541 | cancelCtx: cancel, |
| 542 | metrics: metrics, |
| 543 | selectTiDBTableRegionFunc: selectTiDBTableRegion, |
| 544 | } |
| 545 | d.conf.ServerInfo = version.ServerInfo{ |
| 546 | HasTiKV: true, |
| 547 | ServerType: version.ServerTypeTiDB, |
| 548 | ServerVersion: tableSampleVersion, |
| 549 | } |
| 550 | |
| 551 | testCases := []struct { |
| 552 | handleColNames []string |
| 553 | handleColTypes []string |
| 554 | handleVals [][]driver.Value |
| 555 | expectedWhereClauses []string |
| 556 | hasTiDBRowID bool |
| 557 | }{ |
| 558 | { |
| 559 | []string{}, |
| 560 | []string{}, |
| 561 | [][]driver.Value{}, |
| 562 | nil, |
| 563 | false, |
| 564 | }, |
| 565 | { |
| 566 | []string{"a"}, |
| 567 | []string{"BIGINT"}, |
| 568 | [][]driver.Value{{1}}, |
| 569 | []string{"`a`<1", "`a`>=1"}, |
| 570 | false, |
| 571 | }, |
| 572 | // check whether dumpling can turn to dump whole table |
| 573 | { |
| 574 | []string{"a"}, |
| 575 | []string{"BIGINT"}, |
| 576 | [][]driver.Value{}, |
| 577 | nil, |
| 578 | false, |
| 579 | }, |
| 580 | // check whether dumpling can turn to dump whole table |
| 581 | { |
| 582 | []string{"_tidb_rowid"}, |
nothing calls this directly
no test coverage detected