Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50655 views
1
/*
2
* assert.js: Assertion helpers for broadway tests
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var assert = module.exports = require('assert'),
10
fs = require('fs'),
11
path = require('path'),
12
nconf = require('nconf'),
13
vows = require('vows');
14
15
//
16
// ### Assertion helpers for working with `broadway.App` objects.
17
//
18
assert.app = {};
19
20
//
21
// ### Assertion helpers for working with `broadway.plugins`.
22
//
23
assert.plugins = {};
24
25
//
26
// ### Assert that an application has various plugins.
27
//
28
assert.plugins.has = {
29
config: function (app, config) {
30
assert.instanceOf(app.config, nconf.Provider);
31
if (config) {
32
//
33
// TODO: Assert that all configuration has been loaded
34
//
35
}
36
},
37
exceptions: function (app) {
38
39
},
40
directories: function (app) {
41
if (app.options['directories']) {
42
Object.keys(app.options['directories']).forEach(function (key) {
43
assert.isTrue((fs.existsSync || path.existsSync)(app.options['directories'][key]));
44
});
45
}
46
//assert.isTrue(!!app.config.get('directories'))
47
},
48
log: function (app) {
49
assert.isObject(app.log);
50
51
//
52
// TODO: Assert winston.extend methods
53
//
54
}
55
};
56
57
//
58
// ### Assert that an application doesn't have various plugins
59
//
60
assert.plugins.notHas = {
61
config: function (app) {
62
assert.isTrue(!app.config);
63
},
64
exceptions: function (app) {
65
66
},
67
directories: function (app) {
68
assert.isTrue(!app.config.get('directories'))
69
},
70
log: function (app) {
71
assert.isTrue(!app.log);
72
//
73
// TODO: Assert winston.extend methods
74
//
75
}
76
};
77
78
assert.log = {};
79
80
assert.log.levelMsgMeta = function (err, level, msg, meta) {
81
assert.equal(level, this.event[1]);
82
assert.equal(msg, this.event[2]);
83
assert.equal(meta, this.event[3]);
84
};
85
86
assert.log.msgMeta = function (err, level, msg, meta) {
87
assert.equal(level, this.event[0].split('::')[1] || 'info');
88
assert.equal(msg, this.event[1]);
89
assert.equal(meta, this.event[2]);
90
};
91
92
assert.log.levelMeta = function (err, level, msg, meta) {
93
assert.equal(level, this.event[1]);
94
assert.equal(msg, this.event[0]);
95
assert.deepEqual(meta, this.event[2]);
96
};
97
98
assert.log.levelMsg = function (err, level, msg, meta) {
99
assert.equal(level, this.event[1]);
100
assert.equal(msg, this.event[2]);
101
};
102
103
assert.log.metaOnly = function (err, level, msg, meta) {
104
assert.equal(level, 'info');
105
assert.equal(msg, this.event[0]);
106
assert.equal(meta, this.event[1]);
107
}
108
109