Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
203 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
* This file was automatically generated, editing it manually would be foolish | ||
* | ||
* See https://docs.devwithlando.io/dev/testing.html#functional-tests for more | ||
* information on how all this magic works | ||
* | ||
* title: sql-export-example | ||
* src: examples/sql-export | ||
*/ | ||
// We need these deps to run our tezts | ||
const chai = require('chai'); | ||
const CliTest = require('command-line-test'); | ||
const path = require('path'); | ||
chai.should(); | ||
|
||
// eslint-disable max-len | ||
|
||
describe('sql-export', () => { | ||
// These are tests we need to run to get the app into a state to test | ||
// @todo: It would be nice to eventually get these into mocha before hooks | ||
// so they run before every test | ||
it('boot up a sql export example', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js start').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
// These tests are the main event | ||
// @todo: It would be nice to eventually get these into mocha after hooks | ||
// so they run after every test | ||
it('verify the databases are up and good', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js ssh database -c "mysql -umysql -pmysql data1 -e\"quit\"" && node ../../bin/lando.js ssh database2 -c "psql -U postgres database -c \'\\\dt\'"').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
it('verify our dynamic commands work', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js psql -h database2 -V && node ../../bin/lando.js mysql -V').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
it('import the test mysql file against the default database', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js db-import test.sql').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
it('import the test postgres file to the secondary database', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js db-import -h database2 test2.sql').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
it('verify that we have a users table on both databases', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js ssh database -c "mysql -u mysql -pmysql data1 -e \'show tables;\' | grep users" && node ../../bin/lando.js ssh database2 -c "psql -U postgres -h database2 database -c \'\\\dt\' | grep users"').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
it('export the contents of the dbs', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js db-export && node ../../bin/lando.js db-export -h database2').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
// These are tests we need to run to get the app into a state to test | ||
// @todo: It would be nice to eventually get these into mocha before hooks | ||
// so they run before every test | ||
it('remove the exported d bs', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('rm -f data1.*.gz && rm -f database.*.gz').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
|
||
// These are tests we need to run to get the app into a state to test | ||
// @todo: It would be nice to eventually get these into mocha before hooks | ||
// so they run before every test | ||
it('blow up the sql export example', done => { | ||
process.chdir('examples/sql-export'); | ||
const cli = new CliTest(); | ||
cli.exec('node ../../bin/lando.js destroy -y').then(res => { | ||
if (res.error === null) { | ||
done(); | ||
} else { | ||
done(res.error); | ||
} | ||
}); | ||
process.chdir(path.join('..', '..')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters