(t *testing.T)
| 661 | } |
| 662 | |
| 663 | func TestIsCreateTableDDL(t *testing.T) { |
| 664 | for _, tt := range []struct { |
| 665 | desc string |
| 666 | ddl string |
| 667 | schema string |
| 668 | table string |
| 669 | want bool |
| 670 | }{ |
| 671 | { |
| 672 | desc: "exact match", |
| 673 | ddl: "CREATE TABLE t1 (\n", |
| 674 | table: "t1", |
| 675 | want: true, |
| 676 | }, |
| 677 | { |
| 678 | desc: "given table is prefix of DDL's table", |
| 679 | ddl: "CREATE TABLE t12 (\n", |
| 680 | table: "t1", |
| 681 | want: false, |
| 682 | }, |
| 683 | { |
| 684 | desc: "DDL's table is prefix of given table", |
| 685 | ddl: "CREATE TABLE t1 (\n", |
| 686 | table: "t12", |
| 687 | want: false, |
| 688 | }, |
| 689 | { |
| 690 | desc: "given table has reserved word", |
| 691 | ddl: "CREATE TABLE `create` (\n", |
| 692 | table: "create", |
| 693 | want: true, |
| 694 | }, |
| 695 | { |
| 696 | desc: "given table is regular expression", |
| 697 | ddl: "CREATE TABLE t1 (\n", |
| 698 | table: `..`, |
| 699 | want: false, |
| 700 | }, |
| 701 | { |
| 702 | desc: "given table is invalid regular expression", |
| 703 | ddl: "CREATE TABLE t1 (\n", |
| 704 | table: `[\]`, |
| 705 | want: false, |
| 706 | }, |
| 707 | } { |
| 708 | t.Run(tt.desc, func(t *testing.T) { |
| 709 | if got := isCreateTableDDL(tt.ddl, tt.schema, tt.table); got != tt.want { |
| 710 | t.Errorf("isCreateTableDDL(%q, %q) = %v, but want %v", tt.ddl, tt.table, got, tt.want) |
| 711 | } |
| 712 | }) |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | func TestExtractSchemaAndTable(t *testing.T) { |
| 717 | for _, tt := range []struct { |
nothing calls this directly
no test coverage detected