-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGruntfile.js
61 lines (56 loc) · 1.51 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var async = require('async')
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
mochaTest: {
src: 'test/integration/*',
options: {
timeout: 30000
}
}
})
// Test Setup
grunt.registerTask('createTestData', function () {
var cb = this.async()
var config = require('./conf/local').connectors['appc.oracledb']
var OracleDB = require('oracledb')
OracleDB.getConnection(config, function (err, connection) {
if (err) {
cb(err)
} else {
async.eachSeries([
'DROP TABLE TEST_Post PURGE',
'CREATE TABLE TEST_Post (' +
' id NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY,' +
' title VARCHAR2(255),' +
' content VARCHAR2(255),' +
' CONSTRAINT test_post_id PRIMARY KEY (id)' +
')',
'DROP TABLE TEST_Category PURGE',
'CREATE TABLE TEST_Category (' +
' id NUMBER,' +
' category VARCHAR2(255)' +
')'
],
function (sql, next) {
connection.execute(
sql,
function (err, results) {
if (results && results.rows) {
console.log(results.rows)
}
if (err) {
console.log(err)
}
next()
})
},
cb)
}
})
})
// Load grunt plugins for modules.
grunt.loadNpmTasks('grunt-mocha-test')
// Register tasks.
grunt.registerTask('default', ['createTestData', 'mochaTest'])
}