Skip to content

Commit

Permalink
Adds test that reads multiple fields #16
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Gappa committed Sep 23, 2018
1 parent 3b05f73 commit ec0e2ec
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
17 changes: 17 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ func TestSQL(t *testing.T) {
"db3 3",
},
},
{
name: "reads two fields from all databases",
targetDBs: []string{"all"},
query: "SELECT id, name FROM table1",
expected: []string{
"",
"db1 1 John",
"db1 2 George",
"db1 3 Richard",
"db2 1 Rob",
"db2 2 Ken",
"db2 3 Robert",
"db3 1 Athos",
"db3 2 Porthos",
"db3 3 Aramis",
},
},
}
)
for _, tc := range ts {
Expand Down
15 changes: 9 additions & 6 deletions test_schemas.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ DROP DATABASE IF EXISTS db3;
CREATE DATABASE db3;

CREATE TABLE db1.table1(
id INT(11) NOT NULL
id INT(11) NOT NULL,
name VARCHAR(255) NOT NULL
) ENGINE InnoDB;

CREATE TABLE db2.table1(
id INT(11) NOT NULL
id INT(11) NOT NULL,
name VARCHAR(255) NOT NULL
) ENGINE InnoDB;

CREATE TABLE db3.table1(
id INT(11) NOT NULL
id INT(11) NOT NULL,
name VARCHAR(255) NOT NULL
) ENGINE InnoDB;

INSERT INTO db1.table1 (id) VALUES (1), (2), (3);
INSERT INTO db2.table1 (id) VALUES (1), (2), (3);
INSERT INTO db3.table1 (id) VALUES (1), (2), (3);
INSERT INTO db1.table1 (id, name) VALUES (1, "John"), (2, "George"), (3, "Richard");
INSERT INTO db2.table1 (id, name) VALUES (1, "Rob"), (2, "Ken"), (3, "Robert");
INSERT INTO db3.table1 (id, name) VALUES (1, "Athos"), (2, "Porthos"), (3, "Aramis");

0 comments on commit ec0e2ec

Please sign in to comment.