Skip to content

Commit b9efbff

Browse files
update test to work within permission constraints of db
1 parent 5e14264 commit b9efbff

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

test/queryable/send-native-query.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,54 @@ describe('Queryable ::', function() {
3333

3434
// Store the connection
3535
connection = report.connection;
36-
return done();
36+
37+
// Create a table to use for testing
38+
// Uses sendNativeQuery but doesn't get rows or anything.
39+
// TODO: figure out a query that can run with the given permissions
40+
// that doesn't need an additional table
41+
Pack.sendNativeQuery({
42+
connection: connection,
43+
nativeQuery: 'CREATE TABLE IF NOT EXISTS people(name varchar(255));'
44+
})
45+
.exec(function(err) {
46+
if (err) {
47+
return done(err);
48+
}
49+
50+
return done();
51+
});
3752
});
3853
});
3954
});
4055

4156
// Afterwards release the connection
4257
after(function(done) {
43-
Pack.releaseConnection({
44-
connection: connection
45-
}).exec(done);
58+
Pack.sendNativeQuery({
59+
connection: connection,
60+
nativeQuery: 'DROP TABLE people;'
61+
})
62+
.exec(function(err) {
63+
if (err) {
64+
return done(err);
65+
}
66+
67+
Pack.releaseConnection({
68+
connection: connection
69+
}).exec(done);
70+
});
4671
});
4772

4873
it('should run a native query and return the reports', function(done) {
4974
Pack.sendNativeQuery({
5075
connection: connection,
51-
nativeQuery: 'SHOW GRANTS FOR \'mp\';'
76+
nativeQuery: 'select * from people;'
5277
})
5378
.exec(function(err, report) {
5479
if (err) {
5580
return done(err);
5681
}
5782

5883
assert(_.isArray(report.result.rows));
59-
assert(report.result.rows.length);
6084

6185
return done();
6286
});

0 commit comments

Comments
 (0)