How to use the ok function from assert-plus
Find comprehensive JavaScript assert-plus.ok code examples handpicked from public code repositorys.
84 85 86 87 88 89 90 91 92 93
}); suite.test('cleanup: rm test directory ' + TESTDIR, function (t) { // Sanity checks that we don't `mrm -r` a non-test dir. assert.ok(TESTDIR); assert.ok(TESTDIR.indexOf('node-manta-test') !== -1); forkExecWait({ argv: [ MRM, '-r', TESTDIR ]}, function (err) { t.ifError(err, err); t.end();
41
75
0
545 546 547 548 549 550 551 552 553
assert.optionalString(options.subuser, 'options.subuser'); assert.optionalArrayOfString(options.role, 'options.role'); if (options.sign === null) delete (options.sign); assert.optionalFunc(options.sign, 'options.sign'); assert.ok(options.url || options.socketPath, 'one of options.url or options.socketPath is required'); EventEmitter.call(this);
41
75
0
+ 9 other calls in file
1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
assert.uuid(opts.id, 'opts.id'); assert.arrayOfString(opts.states, 'opts.states'); assert.optionalNumber(opts.interval, 'opts.interval'); assert.func(cb, 'cb'); var interval = (opts.interval === undefined ? 1000 : opts.interval); assert.ok(interval > 0, 'interval must be a positive number'); poll(); function poll() {
38
55
0
+ 167 other calls in file
852 853 854 855 856 857 858 859 860 861
}, function addKeyToRbacConfig(ctx2, next2) { for (i = 0; i < ctx.rbacConfig.users.length; i++) { var u = ctx.rbacConfig.users[i]; if (u.login === c.user) { assert.ok(!u.keys, 'expect no keys on user ' + c.user); u.keys = [ctx2.key]; break; }
38
55
0
156 157 158 159 160 161 162 163 164 165
assert.optionalString(opts.configDir, 'opts.configDir'); assert.optionalObject(opts.log, 'opts.log'); assert.optionalFunc(opts.unlockKeyFn, 'opts.unlockKeyFn'); assert.func(cb, 'cb'); assert.ok(!(opts.profile && opts.profileName), 'cannot specify both opts.profile and opts.profileName'); assert.ok(!(!opts.profile && !opts.profileName), 'must specify one opts.profile or opts.profileName'); assert.ok(!(opts.config && opts.configDir),
38
55
0
+ 4 other calls in file
GitHub: TritonDataCenter/moray
180 181 182 183 184 185 186 187 188 189 190
/* * Set a timeout for queries ("queryTimeout" in the configuration). */ PGClient.prototype.setTimeout = function setQueryTimeout(timeout) { assert.finite(timeout, 'timeout'); assert.ok(timeout >= 0, 'timeout >= 0'); this._queryTimeout = timeout; };
21
60
0
+ 15 other calls in file
230 231 232 233 234 235 236 237 238 239 240
* combined to form a JSON predicate. Valid values are 'or' and 'and'. */ function jsonPredFromKv(kvs, validKeys, compositionType) { assert.arrayOfString(kvs, 'kvs'); assert.string(compositionType, 'string'); assert.ok(compositionType === 'or' || compositionType === 'and', 'compositionType'); var keyName; var predicate = {};
38
55
41
+ 3 other calls in file
704 705 706 707 708 709 710 711 712 713
* if wanted. */ function ping(opts, cb) { assert.func(cb, 'cb'); assert.object(opts, 'opts'); assert.ok(opts.index || opts.indexName, 'opts.index or opts.indexName is required'); assert.optionalObject(opts.log, 'opts.log'); // HTTP client basic options: assert.optionalBool(opts.insecure, 'opts.insecure');
35
59
0
+ 3 other calls in file
GitHub: restify/clients
665 666 667 668 669 670 671 672 673 674
if (options.url) { var parsedUrl = url.parse( // trim whitespace from the url which would mess up parsing options.url.replace(/\s/g, '') ); assert.ok( parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:', 'must specify http/https protocol!' ); this.url = parsedUrl;
34
55
0
+ 3 other calls in file
24 25 26 27 28 29 30 31 32 33 34 35
function CreateInstanceProcedure(opts) { assert.string(opts.svcName, 'opts.svcName'); assert.arrayOfString(opts.serverNames, 'opts.serverNames'); assert.ok(opts.serverNames.length > 0, 'at least one server name'); assert.optionalUuid(opts.imageUuid, 'opts.imageUuid'); assert.optionalString(opts.imageChannel, 'opts.imageChannel'); assert.optionalBool(opts.skipHACheck, 'opts.skipHACheck');
19
13
0
GitHub: TritonDataCenter/sdcadm
437 438 439 440 441 442 443 444 445 446
// when provisioning these storage VMs. Thus these packages need to be // added into PAPI before any NFS shared volume can be created. function addSharedVolumesPackages(ctx, next) { function createPackageSettings(packageSize) { assert.number(packageSize, 'packageSize'); assert.ok(packageSize > 0); return { size: packageSize, owner_uuids: [self.sdcadm.config.ufds_admin_uuid]
19
13
0
122 123 124 125 126 127 128 129 130 131 132
} exports.setUp = function (callback) { common.setUp(function (err, _client) { assert.ifError(err); assert.ok(_client, 'restify client'); client = _client; callback(); }); };
20
11
0
175 176 177 178 179 180 181 182 183 184
* From a string representing an application model name "modelName", returns its * corresponding Moray bucket name. */ Moray.prototype._modelToBucketName = function _modelToBucketName(modelName) { assert.string(modelName, 'modelName'); assert.ok(this._bucketsConfig[modelName], 'this._bucketsConfig[' + modelName + ']'); return this._bucketsConfig[modelName].name; };
20
11
0
463 464 465 466 467 468 469 470 471 472
if (volumes && volumes.length > 0) { log.debug({volumes: volumes}, 'VM is used as volume storage'); mod_assert.ok(volumes.length <= 1); ctx.volume = volumes[0]; } else { log.debug('VM is not used as volume storage'); }
6
8
0
+ 3 other calls in file
15 16 17 18 19 20 21 22 23
assert.object(options, 'options'); assert.optionalArrayOfUuid(options.missing, 'options.missing'); assert.optionalArrayOfUuid(options.nonOwned, 'options.nonOwned'); assert.optionalArrayOfUuid(options.nonFabric, 'options.nonFabric'); assert.ok((options.missing && options.missing.length > 0) || (options.nonOwned && options.nonOwned.length > 0) || (options.nonFabric && options.nonFabric.length > 0), 'at least one network needs to be missing, non-owned or non-fabric');
6
8
0
GitHub: TritonDataCenter/sdc-manta
975 976 977 978 979 980 981 982 983 984
'unsupported alarm state: "%s"', args.sources.alarms.state ); } assertplus.ok( !args.sources.alarms.hasOwnProperty('alarmIds'), 'cannot specify "sources.alarms.state" and ' + '"sources.alarms.alarmIds"' );
13
7
42
+ 7 other calls in file
73 74 75 76 77 78 79 80 81 82
chan.name, CHANNEL_NAME_RE)); assert.string(chan.description, 'config.channels['+i+'].description'); if (chan.hasOwnProperty('default')) { assert.bool(chan.default, 'config.channels['+i+'].default'); if (defaultChannel) { assert.ok(false, format('cannot have multiple *default* channels: %j and %j', defaultChannel, chan)); } defaultChannel = chan;
17
5
0
+ 2 other calls in file
75 76 77 78 79 80 81 82 83 84 85 86
doCreateVolume(this, params, options, callback); }; function hrtimeToMs(hrtime) { assert.arrayOfNumber(hrtime, 'hrtime'); assert.ok(hrtime.length === 2, 'hrtime must be an array of length 2'); var MSECS_PER_SEC = 1000; var NSECS_PER_MSEC = 1e6;
13
2
0
428 429 430 431 432 433 434 435 436 437 438
*/ function UFDS(opts) { assert.object(opts, 'options'); assert.string(opts.bindDN, 'options.bindDN'); assert.string(opts.bindPassword, 'options.bindPassword'); assert.ok(!opts.bindCredentials, 'options.bindCredentials not supported'); assert.optionalObject(opts.log, 'options.log'); assert.string(opts.url, 'options.url'); var self = this;
9
3
0
+ 3 other calls in file
282 283 284 285 286 287 288 289 290 291
var matches; var peerObj = {}; matches = line.match(PEER_REGEXP); mod_assert.ok(matches, 'peer lines should match ' + PEER_REGEXP.toString() + ', got: ' + line); peerObj = { state: translateFlash(matches[1]),
8
3
0
+ 15 other calls in file
assert-plus.object is the most popular function in assert-plus (2295 examples)