(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestSQLExport(t *testing.T) { |
| 22 | tests := []struct { |
| 23 | databaseName string |
| 24 | dbType storepb.Engine |
| 25 | prepareStatement string |
| 26 | exportTests []struct { |
| 27 | format v1pb.ExportFormat |
| 28 | statement string |
| 29 | password string |
| 30 | results []struct { |
| 31 | statement string |
| 32 | content string |
| 33 | } |
| 34 | } |
| 35 | }{ |
| 36 | { |
| 37 | databaseName: "Test1", |
| 38 | dbType: storepb.Engine_MYSQL, |
| 39 | prepareStatement: ` |
| 40 | CREATE TABLE tbl(id INT PRIMARY KEY, name VARCHAR(64), gender BIT(1), height BIT(8)); |
| 41 | INSERT INTO Test1.tbl (id, name, gender, height) VALUES(1, 'Alice', B'0', B'01111111'); |
| 42 | `, |
| 43 | exportTests: []struct { |
| 44 | format v1pb.ExportFormat |
| 45 | statement string |
| 46 | password string |
| 47 | results []struct { |
| 48 | statement string |
| 49 | content string |
| 50 | } |
| 51 | }{ |
| 52 | { |
| 53 | format: v1pb.ExportFormat_JSON, |
| 54 | password: "123", |
| 55 | statement: "SELECT * FROM Test1.tbl;", |
| 56 | results: []struct { |
| 57 | statement string |
| 58 | content string |
| 59 | }{ |
| 60 | { |
| 61 | statement: "SELECT * FROM Test1.tbl;", |
| 62 | content: `[ |
| 63 | { |
| 64 | "gender": "AA==", |
| 65 | "height": "fw==", |
| 66 | "id": 1, |
| 67 | "name": "Alice" |
| 68 | } |
| 69 | ]`, |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | { |
| 74 | format: v1pb.ExportFormat_CSV, |
| 75 | statement: "SELECT * FROM Test1.tbl;", |
| 76 | results: []struct { |
| 77 | statement string |
| 78 | content string |
nothing calls this directly
no test coverage detected