MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestExportSQL

Function TestExportSQL

backend/component/export/export_test.go:70–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestExportSQL(t *testing.T) {
71 tests := []struct {
72 engine storepb.Engine
73 statementPrefix string
74 result *v1pb.QueryResult
75 want string
76 }{
77 {
78 engine: storepb.Engine_MYSQL,
79 statementPrefix: "INSERT INTO `<table_name>` (`a`) VALUES (",
80 result: &v1pb.QueryResult{
81 Rows: []*v1pb.QueryRow{
82 {
83 Values: []*v1pb.RowValue{
84 {
85 Kind: &v1pb.RowValue_BoolValue{BoolValue: true},
86 },
87 {
88 Kind: &v1pb.RowValue_StringValue{StringValue: "abc"},
89 },
90 {
91 Kind: &v1pb.RowValue_NullValue{},
92 },
93 },
94 },
95 {
96 Values: []*v1pb.RowValue{
97 {
98 Kind: &v1pb.RowValue_BoolValue{BoolValue: false},
99 },
100 {
101 Kind: &v1pb.RowValue_StringValue{StringValue: "abc"},
102 },
103 {
104 Kind: &v1pb.RowValue_NullValue{},
105 },
106 },
107 },
108 },
109 },
110 want: "INSERT INTO `<table_name>` (`a`) VALUES (true,'abc',NULL);\nINSERT INTO `<table_name>` (`a`) VALUES (false,'abc',NULL);",
111 },
112 {
113 engine: storepb.Engine_MYSQL,
114 statementPrefix: "INSERT INTO `<table_name>` (`a`) VALUES (",
115 result: &v1pb.QueryResult{
116 Rows: []*v1pb.QueryRow{
117 {
118 Values: []*v1pb.RowValue{
119 {
120 Kind: &v1pb.RowValue_StringValue{StringValue: "a\nbc"},
121 },
122 },
123 },
124 },
125 },
126 want: "INSERT INTO `<table_name>` (`a`) VALUES ('a\\nbc');",
127 },

Callers

nothing calls this directly

Calls 2

SQLFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected