1717const assert = require ( 'assert' ) ;
1818const path = require ( 'path' ) ;
1919const Knex = require ( 'knex' ) ;
20- const tools = require ( '@google-cloud/nodejs-repo-tools ' ) ;
20+ const { exec } = require ( 'child_process ' ) ;
2121
2222const cwd = path . join ( __dirname , '..' ) ;
2323
@@ -41,20 +41,25 @@ before(async () => {
4141 }
4242} ) ;
4343
44- it ( 'should create a table' , async ( ) => {
45- const output = await tools . runAsync (
44+ it ( 'should create a table' , done => {
45+ exec (
4646 `node createTable.js ${ DB_USER } ${ DB_PASS } ${ DB_NAME } ${ CONNECTION_NAME } ` ,
47- cwd
47+ { cwd} ,
48+ ( err , stdout ) => {
49+ assert . ok ( stdout . includes ( `Successfully created 'votes' table.` ) ) ;
50+ done ( ) ;
51+ }
4852 ) ;
49- assert . ok ( output . includes ( `Successfully created 'votes' table.` ) ) ;
5053} ) ;
5154
52- it ( 'should handle existing tables' , async ( ) => {
53- const { stderr } = await tools . runAsyncWithIO (
55+ it ( 'should handle existing tables' , done => {
56+ exec (
5457 `node createTable.js ${ DB_USER } ${ DB_PASS } ${ DB_NAME } ${ CONNECTION_NAME } ` ,
55- cwd
58+ { cwd} ,
59+ ( err , stdout , stderr ) => {
60+ assert . ok ( stderr . includes ( "Failed to create 'votes' table:" ) ) ;
61+ assert . ok ( stderr . includes ( 'already exists' ) ) ;
62+ done ( ) ;
63+ }
5664 ) ;
57-
58- assert . ok ( stderr . includes ( "Failed to create 'votes' table:" ) ) ;
59- assert . ok ( stderr . includes ( 'already exists' ) ) ;
6065} ) ;
0 commit comments