MCPcopy Create free account
hub / github.com/actiontech/dtle / TestBinlogReader_resolveQuery

Function TestBinlogReader_resolveQuery

driver/mysql/binlog/binlog_reader_test.go:304–369  ·  view source on GitHub ↗

func Test_loadMapping(t *testing.T) { replicateDoDbWithRename := []*common.DataSource{ { TableSchema: "db1", TableSchemaRename: "db1-rename", Tables: []*common.Table{ { TableName: "tb1", TableRename: "db1-tb1-rename", TableSchema: "db1",

(t *testing.T)

Source from the content-addressed store, hash-verified

302//}
303
304func TestBinlogReader_resolveQuery(t *testing.T) {
305 skipFunc1 := func(schema string, tableName string) bool {
306 return schema == "skip" || tableName == "skip"
307 }
308 b := &BinlogReader{
309 lowerCaseTableNames: mysqlconfig.LowerCaseTableNames0,
310 logger: hclog.Default(),
311 }
312
313 type args struct {
314 currentSchema string
315 sql string
316 }
317 tests := []struct {
318 name string
319 args args
320 wantResult parseQueryResult
321 wantErr bool
322 }{
323 {
324 name: "drop-table-1",
325 args: args{
326 currentSchema: "",
327 sql: "drop table a.b, skip.c, d",
328 },
329 wantResult: parseQueryResult{
330 sql: "DROP TABLE `a`.`b`, `d`",
331 },
332 wantErr: false,
333 }, {
334 name: "drop-table-2",
335 args: args{
336 currentSchema: "",
337 sql: "drop table if exists skip.b, skip.c",
338 },
339 wantResult: parseQueryResult{
340 sql: "DROP TABLE IF EXISTS `skip`.`b`",
341 },
342 wantErr: false,
343 }, {
344 name: "empty",
345 args: args{
346 currentSchema: "",
347 sql: "",
348 },
349 wantResult: parseQueryResult{
350 isRecognized: false,
351 sql: "",
352 },
353 wantErr: false,
354 },
355 }
356 for _, tt := range tests {
357 t.Run(tt.name, func(t *testing.T) {
358 gotResult, err := b.resolveQuery(tt.args.currentSchema, tt.args.sql, skipFunc1)
359 if (err != nil) != tt.wantErr {
360 t.Errorf("resolveQuery() error = %v, wantErr %v", err, tt.wantErr)
361 return

Callers

nothing calls this directly

Calls 2

resolveQueryMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected