Skip to content

Commit f5ce38b

Browse files
author
Joshua Baert
committed
Finished node to CLI test.. We can run test so long as we get the text into a string
1 parent a7f153a commit f5ce38b

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

controllers/testCtrl.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
/**
22
* Created by Joshua Baert on 12/15/2016.
3+
*
4+
* This Controller is where we take take a script as a string then run our tests against it
5+
*
36
*/
47

58
const exec = require('child_process').exec;
69

7-
exec('docker run --rm codewars/node-runner run -l javascript -c "var a = 1;" -t cw -f "Test.assertEquals(a, 1)"', (err, stdout, stderr)=> {
8-
if (err) console.log('err', err);
9-
console.log(typeof stdout);
10-
console.log('stdout', stdout);
11-
console.log('stderr', stderr);
12-
});
10+
let script = `let addTwo = (x) => {return x+2};`;
11+
let test = `Test.assertEquals(addTwo(2), 4)`;
12+
13+
14+
// This is where wer run a script.. I have verified that so long as we get it in string format we run unit tests
15+
exec(`docker run --rm codewars/node-runner run -l javascript -c "${script}" -t cw -f "${test}"`,
16+
(err, stdout, stderr) => {
17+
if (err) console.log('err', err);
18+
console.log(typeof stdout);
19+
console.log('stdout', stdout);
20+
console.log('stderr', stderr);
21+
});
22+
23+

0 commit comments

Comments
 (0)