This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
forked from danthareja/node-google-apps-script
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start a basic functional test framework.
We use a standard TAP functional test format with `tNNN*.js` test scripts under a `t/` subdirectory. These can be run directly from the project root with `node t/t001.js` or similar, and later the build system will be extended to find and run tests automatically. The `t/tlib.js` file is a library of handy support functions for this, including bringing it various test tools (tape, tape-spawn, etc.) and functions to read in data files that store expected output and whatnot. tlib itself is tested with `t/t001-tlib.js`. The first test of the non-test-framework code is `t010-version.js`, which proves we can run the `gapps` binary.
- Loading branch information
Showing
5 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict' | ||
const tlib = require('./tlib')(module) | ||
|
||
tlib.test('readTestData', (t) => { | ||
t.equal('A file containing expected output.\n', | ||
tlib.readTestData(tlib.testData('expected'))) | ||
t.end() | ||
}) |
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 @@ | ||
A file containing expected output. |
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,12 @@ | ||
'use strict' | ||
const tlib = require('./tlib')(module) | ||
|
||
// Smoke test for the command line program. | ||
tlib.test('version', (t) => { | ||
const | ||
expected = require('../package.json').version + '\n', | ||
cmd = tlib.spawn(t, './bin/gapps -V') | ||
cmd.succeeds() | ||
cmd.stdout.match(expected) | ||
cmd.end() | ||
}) |
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,22 @@ | ||
const | ||
fs = require('fs'), | ||
path = require('path'), | ||
_ = require('lodash') | ||
|
||
function testData(test_module, p) { | ||
const | ||
dir = path.dirname(test_module.filename), | ||
subdir = path.basename(test_module.filename, '.js').split('-')[0] | ||
return path.join(dir, subdir, p) | ||
} | ||
|
||
function readTestData(p) { | ||
return fs.readFileSync(p, { encoding: 'UTF-8' }) | ||
} | ||
|
||
module.exports = (test_module) => { return { | ||
test: require('tape'), | ||
spawn: require('tape-spawn'), | ||
testData: _.partial(testData, test_module), | ||
readTestData: readTestData, | ||
}} |