blob: 77442cd3527d771f2895a780c2b0a5668780e283 [file] [log] [blame]
Ali Ghassemifcab3c32014-09-12 14:24:12 -07001var test = require('prova');
Ali Ghassemia8b15482014-10-20 12:47:01 -07002var mercury = require('mercury');
Ali Ghassemifcab3c32014-09-12 14:24:12 -07003var _ = require('lodash');
4var proxyquire = require('proxyquireify')(require);
5var mockLRUCache = require('./mocks/lru-cache');
Ali Ghassemifcab3c32014-09-12 14:24:12 -07006
Ali Ghassemia35f0422014-09-26 09:04:04 -07007// @noCallThru ensures this completely overrdies the original config
8// instead of inheriting the properties that are not defined here from
9// the original dependency
Ali Ghassemifcab3c32014-09-12 14:24:12 -070010var veyronConfigForTest = {
Ali Ghassemia35f0422014-09-26 09:04:04 -070011 '@noCallThru': true
Ali Ghassemifcab3c32014-09-12 14:24:12 -070012};
13
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -080014// The NAMESPACE_ROOT environment variable is set by servicerunner in the "make
15// test" target. That environment variable is picked up by the "envify" prova
16// transform and used to set process.env.NAMESPACE_ROOT.
17var globalRoot = process.env.NAMESPACE_ROOT;
18
Ali Ghassemifcab3c32014-09-12 14:24:12 -070019// Require namespaceService but using test specific mocks and configs
20var namespaceService =
21 proxyquire('../../../../src/services/namespace/service.js', {
22 '../../veyron-config': veyronConfigForTest,
23 'lru-cache': function() {
24 return mockLRUCache;
25 }
26 });
27
Ali Ghassemifcab3c32014-09-12 14:24:12 -070028test('getChildren of default namespace root', function(t) {
Ali Ghassemibbb20532014-09-22 15:05:58 -070029 namespaceService.getChildren().
30 then(function assertResult(result) {
Ali Ghassemi11256942014-10-08 15:14:49 -070031 assertIsImmutable(t, result);
Ali Ghassemi9c5cc192014-11-19 18:31:05 -080032 // Wait until we finish, we expect 2 top level items: cottage, house
33 result.events.on('end', function validate() {
Ali Ghassemi2a60a252014-11-13 09:00:23 -080034 mercury.watch(result, function(children) {
Ali Ghassemi01811a32014-11-04 13:58:34 -080035 assertCottage(children[0]);
36 assertHouse(children[1]);
Ali Ghassemid94e91c2014-10-01 11:22:46 -070037 t.end();
Ali Ghassemi2a60a252014-11-13 09:00:23 -080038 });
Ali Ghassemi9c5cc192014-11-19 18:31:05 -080039 });
Ali Ghassemi65ee3262015-02-23 11:36:59 -080040 result.events.on('globError', function(error) {
41 t.notOk(error, 'did not expect any globs errors');
42 t.end();
43 });
Ali Ghassemid94e91c2014-10-01 11:22:46 -070044 }).catch(t.end);
Ali Ghassemifcab3c32014-09-12 14:24:12 -070045
Ali Ghassemif2540c92014-10-01 09:00:15 -070046 function assertCottage(item) {
Ali Ghassemi43064312014-10-14 17:24:32 -070047 assertServer(t, item, {
48 name: 'cottage',
49 objectName: 'cottage',
50 isGlobbable: true,
51 type: 'mounttable'
52 });
Ali Ghassemifcab3c32014-09-12 14:24:12 -070053 }
54
55 function assertHouse(item) {
Ali Ghassemi43064312014-10-14 17:24:32 -070056 assertServer(t, item, {
57 name: 'house',
58 objectName: 'house',
59 isGlobbable: true,
60 type: 'mounttable'
61 });
Ali Ghassemifcab3c32014-09-12 14:24:12 -070062 }
63});
64
65test('getChildren of cottage/lawn', function(t) {
Ali Ghassemibbb20532014-09-22 15:05:58 -070066 namespaceService.getChildren('cottage/lawn').
67 then(function assertResult(result) {
Ali Ghassemi11256942014-10-08 15:14:49 -070068 assertIsImmutable(t, result);
Ali Ghassemi9c5cc192014-11-19 18:31:05 -080069 // Wait until we finish, we expect 3 items back, front and master-sprinkler
70 result.events.on('end', function validate() {
71 mercury.watch(result, function(children) {
Ali Ghassemibbb20532014-09-22 15:05:58 -070072 assertBack(children[0]);
73 assertSprinkler(children[2]);
Ali Ghassemid94e91c2014-10-01 11:22:46 -070074 t.end();
Ali Ghassemi9c5cc192014-11-19 18:31:05 -080075 });
Ali Ghassemibbb20532014-09-22 15:05:58 -070076 });
Ali Ghassemi65ee3262015-02-23 11:36:59 -080077 result.events.on('globError', function(error) {
78 t.notOk(error, 'did not expect any globs errors');
79 t.end();
80 });
Ali Ghassemibbb20532014-09-22 15:05:58 -070081 }).catch(t.end);
Ali Ghassemifcab3c32014-09-12 14:24:12 -070082
83 function assertSprinkler(item) {
Ali Ghassemi43064312014-10-14 17:24:32 -070084 assertServer(t, item, {
85 name: 'master-sprinkler',
86 objectName: 'cottage/lawn/master-sprinkler',
87 isGlobbable: false,
88 type: 'unknown'
89 });
Ali Ghassemifcab3c32014-09-12 14:24:12 -070090 }
91
92 function assertBack(item) {
Ali Ghassemi43064312014-10-14 17:24:32 -070093 assertIntermediaryName(t, item, {
94 name: 'back',
95 objectName: 'cottage/lawn/back'
96 });
Ali Ghassemifcab3c32014-09-12 14:24:12 -070097 }
98});
99
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -0800100test('getChildren of rooted ' + globalRoot + '/house/kitchen', function(t) {
101 namespaceService.getChildren(globalRoot + '/house/kitchen').
Ali Ghassemibbb20532014-09-22 15:05:58 -0700102 then(function assertResult(result) {
Ali Ghassemi11256942014-10-08 15:14:49 -0700103 assertIsImmutable(t, result);
Ali Ghassemi9c5cc192014-11-19 18:31:05 -0800104 // Wait until we finish, we expect 2 items, lights and smoke-detector
105 result.events.on('end', function validate() {
106 mercury.watch(result, function(children) {
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700107 assertLightSwitch(children[0]);
108 assertSmokeDetector(children[1]);
Ali Ghassemibbb20532014-09-22 15:05:58 -0700109 t.end();
Ali Ghassemi9c5cc192014-11-19 18:31:05 -0800110 });
Ali Ghassemibbb20532014-09-22 15:05:58 -0700111 });
Ali Ghassemi65ee3262015-02-23 11:36:59 -0800112 result.events.on('globError', function(error) {
113 t.notOk(error, 'did not expect any globs errors');
114 t.end();
115 });
Ali Ghassemibbb20532014-09-22 15:05:58 -0700116 }).catch(t.end);
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700117
Alex Fandrianto4204a882014-09-19 13:34:32 -0700118 function assertLightSwitch(item) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700119 assertServer(t, item, {
120 name: 'lights',
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -0800121 objectName: globalRoot + '/house/kitchen/lights',
Ali Ghassemi43064312014-10-14 17:24:32 -0700122 isGlobbable: false,
123 type: 'unknown'
124 });
Alex Fandrianto4204a882014-09-19 13:34:32 -0700125 }
126
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700127 function assertSmokeDetector(item) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700128 assertServer(t, item, {
129 name: 'smoke-detector',
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -0800130 objectName: globalRoot + '/house/kitchen/smoke-detector',
131 isGlobbable: false,
132 type: 'unknown'
133 });
134 }
135});
136
137// The HOUSE_MOUNTTABLE environment variable is set by run-tests.sh. That
138// environment variable is picked up by the "envify" prova transform and used to
139// set process.env.HOUSE_MOUNTTABLE.
140var hostPortRoot = process.env.HOUSE_MOUNTTABLE;
141
142test('getChildren of rooted ' + hostPortRoot + '/kitchen', function(t) {
143 namespaceService.getChildren(hostPortRoot + '/kitchen').
144 then(function assertResult(result) {
145 assertIsImmutable(t, result);
146 // Wait until we finish, we expect 2 items, lights and smoke-detector
147 result.events.on('end', function validate() {
148 mercury.watch(result, function(children) {
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -0800149 assertLightSwitch(children[0]);
150 assertSmokeDetector(children[1]);
151 t.end();
152 });
153 });
Ali Ghassemi65ee3262015-02-23 11:36:59 -0800154 result.events.on('globError', function(error) {
155 t.notOk(error, 'did not expect any globs errors');
156 t.end();
157 });
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -0800158 }).catch(t.end);
159
160 function assertLightSwitch(item) {
161 assertServer(t, item, {
162 name: 'lights',
163 objectName: hostPortRoot + '/kitchen/lights',
164 isGlobbable: false,
165 type: 'unknown'
166 });
167 }
168
169 function assertSmokeDetector(item) {
170 assertServer(t, item, {
171 name: 'smoke-detector',
172 objectName: hostPortRoot + '/kitchen/smoke-detector',
Ali Ghassemi43064312014-10-14 17:24:32 -0700173 isGlobbable: false,
174 type: 'unknown'
175 });
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700176 }
177});
178
Ali Ghassemia7b255a2014-11-26 13:06:56 -0800179test('getChildren of non-existing mounttable', function(t) {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700180 // TODO(aghassemi) why does namespace library return empty results instead of
181 // error when globbing rooted names that don't exist?
Ali Ghassemibbb20532014-09-22 15:05:58 -0700182 namespaceService.getChildren('/DoesNotExist:666/What/Ever').
Ali Ghassemia8b15482014-10-20 12:47:01 -0700183 then(function assertResult(result) {
Ali Ghassemi9c5cc192014-11-19 18:31:05 -0800184 result.events.on('end', function validate() {
185 // Expect empty results
186 mercury.watch(result, function(children) {
187 t.deepEqual(children, []);
188 t.end();
189 });
Ali Ghassemia8b15482014-10-20 12:47:01 -0700190 });
Ali Ghassemi65ee3262015-02-23 11:36:59 -0800191 result.events.on('globError', function(error) {
192 // we do actually expect a glob error in this case
Ali Ghassemi218fa082014-12-01 17:00:38 -0800193 t.ok(error);
194 });
Ali Ghassemia8b15482014-10-20 12:47:01 -0700195 }).catch(t.end);
Ali Ghassemibbb20532014-09-22 15:05:58 -0700196});
197
Ali Ghassemia8b15482014-10-20 12:47:01 -0700198test('getNamespaceItem of leaf server', function(t) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700199 namespaceService.getNamespaceItem('cottage/lawn/master-sprinkler').
200 then(function assertItem(itemObs) {
201 assertIsImmutable(t, itemObs);
202 var item = itemObs();
203 assertServer(t, item, {
204 name: 'master-sprinkler',
205 objectName: 'cottage/lawn/master-sprinkler',
206 isGlobbable: false,
207 type: 'unknown'
208 });
209 t.end();
210 }).catch(t.end);
211});
212
Ali Ghassemia8b15482014-10-20 12:47:01 -0700213test('getNamespaceItem of intermediary name', function(t) {
214 namespaceService.getNamespaceItem('cottage/lawn/back').
Ali Ghassemi43064312014-10-14 17:24:32 -0700215 then(function assertItem(itemObs) {
216 assertIsImmutable(t, itemObs);
217 var item = itemObs();
218 assertIntermediaryName(t, item, {
219 name: 'back',
220 objectName: 'cottage/lawn/back'
221 });
222 t.end();
223 }).catch(t.end);
224});
225
Ali Ghassemi9c5cc192014-11-19 18:31:05 -0800226test('getNamespaceItem of mounttable leaf server', function(t) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700227 namespaceService.getNamespaceItem('cottage').
228 then(function assertItem(itemObs) {
229 assertIsImmutable(t, itemObs);
230 var item = itemObs();
231 assertServer(t, item, {
232 name: 'cottage',
233 objectName: 'cottage',
234 isGlobbable: true,
235 type: 'mounttable'
236 });
237 t.end();
238 }).catch(t.end);
239});
240
Ali Ghassemia8b15482014-10-20 12:47:01 -0700241test('search uses caching', function(t) {
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700242 mockLRUCache.reset();
243
Ali Ghassemia8b15482014-10-20 12:47:01 -0700244 namespaceService.search('house', '*').
Ali Ghassemibbb20532014-09-22 15:05:58 -0700245 then(function assertNoCacheHit() {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700246 t.notOk(mockLRUCache.wasCacheHit('glob|house/*'),
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700247 'first glob call is not a cache hit');
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700248
Ali Ghassemibbb20532014-09-22 15:05:58 -0700249 // Call second time, there should have been a cache hit
Ali Ghassemia8b15482014-10-20 12:47:01 -0700250 return namespaceService.search('house', '*');
Ali Ghassemi43064312014-10-14 17:24:32 -0700251 }).then(function assertCacheHit() {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700252 t.ok(mockLRUCache.wasCacheHit('glob|house/*'),
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700253 'second glob call is a cache hit');
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700254
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700255 // Call glob with same name, different query
Ali Ghassemia8b15482014-10-20 12:47:01 -0700256 return namespaceService.search('house', 'foo*');
Ali Ghassemibbb20532014-09-22 15:05:58 -0700257 }).then(function assertNoCacheHit() {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700258 t.notOk(mockLRUCache.wasCacheHit('glob|house/foo*'),
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700259 'third glob call with different query is not a cache hit');
260 t.end();
Ali Ghassemibbb20532014-09-22 15:05:58 -0700261 }).catch(t.end);
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700262});
263
264test('getSignature uses caching', function(t) {
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700265 mockLRUCache.reset();
266
267 namespaceService.getSignature('house/alarm').then(function() {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700268 t.notOk(mockLRUCache.wasCacheHit('getSignature|house/alarm'),
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700269 'first getSignature call is not a cache hit');
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700270 // Call a second time
271 return namespaceService.getSignature('house/alarm');
272 }).then(function() {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700273 t.ok(mockLRUCache.wasCacheHit('getSignature|house/alarm'),
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700274 'second getSignature call is a cache hit');
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700275 // Call a different name
276 return namespaceService.getSignature('house/kitchen/smoke-detector');
277 }).then(function() {
Ali Ghassemia8b15482014-10-20 12:47:01 -0700278 t.notOk(mockLRUCache.wasCacheHit(
279 'getSignature|house/kitchen/smoke-detector'
280 ),'third getSignature call to a different name is not a cache hit');
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700281 t.end();
Ali Ghassemi980a3792014-10-01 13:54:03 -0700282 }).catch(t.end);
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700283});
284
285//TODO(aghassemi)
286//Tests for:
287// Recursive glob
288// Glob with some keyword
289// Ensuring array is updated when nodes get mounted and unmounted (when we use
290// watchGlob)
Alex Fandrianto81b31842014-10-14 09:54:02 -0700291
292// Make RPC: good inputs => no error
293var okRPCs = {
294 'no input': ['house/alarm', 'status', []],
295 'bool input': ['house/living-room/lights', 'flipSwitch', [true]],
296 'int input': ['cottage/smoke-detector', 'sensitivity', [2]],
297 'float input': ['house/alarm', 'delayArm', [2.5]],
298 'string input': ['cottage/pool/speaker', 'playSong', ['Happy Birthday']],
299 'slice input': ['house/master-bedroom/speaker', 'addSongs', [['A', 'B']]],
300 '2+ inputs': ['cottage/pool/heater', 'start', [70, 5]],
301};
302
303_.forOwn(okRPCs, function run(params, inputType) {
304 test(
305 'makeRPC accepts good input - ' + inputType,
306 testMakeRPCNoError.bind(null, params)
307 );
308});
309
310// Make RPC: bad inputs => error
311var badRPCs = {
Ali Ghassemi78e3bc82014-11-30 11:53:43 -0800312 //TODO(aghassemi) re-enable after #483
313 //'no service': ['mansion/smoke-detector', 'status', []],
Alex Fandrianto81b31842014-10-14 09:54:02 -0700314 'no method': ['cottage/pool/speaker', 'status', []],
315 'no input': ['cottage/lights','flipSwitch', null],
316 'bad type': ['cottage/lights','flipSwitch', ['notBool']],
317 'lacks input': ['cottage/pool/heater','start', [80]],
318 'invalid input': ['house/living-room/blast-speaker','playSong', ['notThere']]
319};
320
321_.forOwn(badRPCs, function run(params, inputType) {
322 test(
323 'makeRPC errors on bad input - ' + inputType,
324 testMakeRPCHasError.bind(null, params)
325 );
326});
327
328// Make RPC: outputs have the expected # of outputs
329test('makeRPC returns output properly', function(t) {
330 namespaceService.makeRPC('cottage/alarm', 'panic', []).then(
Alex Fandriantodb090a62015-01-16 15:05:03 -0800331 function got0Outputs(res) { // 0 outputs: has no result.
332 t.ok(res === undefined, '0 outputs => is undefined');
Alex Fandrianto81b31842014-10-14 09:54:02 -0700333
334 return namespaceService.makeRPC('house/alarm', 'status', []);
335 }
336 ).then( // 1 output: (Non-array/slice output) is not an Array.
337 function got1Output(res) {
338 t.notOk(res instanceof Array, '1 output => not an Array');
339
340 return namespaceService.makeRPC('cottage/smoke-detector', 'test', []);
341 }
342 ).then( // 1 output: Delayed return. Also not an array.
343 function got1OutputDelayed(res) {
344 t.notOk(res instanceof Array, '1 output => not an Array');
345
346 return namespaceService.makeRPC('cottage/pool/heater', 'status', []);
347 }
348 ).then( // 2 outputs: Is an Array of the correct length.
349 function got2Outputs(res) {
350 var ok = res instanceof Array && res.length === 2;
351 t.ok(ok, '2 outputs => length 2 Array');
352 t.end();
353 }
354 ).catch(t.end);
355});
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700356
357/*
358 * Test helpers
359 */
Ali Ghassemi43064312014-10-14 17:24:32 -0700360function assertServer(t, item, vals) {
361 assertMountedName(t, item, vals.name);
362 assertObjectName(t, item, vals.objectName);
363 assertIsServer(t, item);
364 if (vals.isGlobbable === true) {
365 assertIsGlobbable(t, item);
366 } else if(vals.isGlobbable === false) {
367 assertIsNotGlobbable(t, item);
368 }
Ali Ghassemi43064312014-10-14 17:24:32 -0700369
370 if (vals.type === 'unknown') {
371 assertUnknownServiceTypeInfo(t, item);
372 } else if (vals.type === 'mounttable') {
373 assertMounttableServiceTypeInfo(t, item);
374 } else {
375 t.fail('Unknown type: ' + vals.type);
376 }
377}
378
379function assertIntermediaryName(t, item, vals) {
380 assertMountedName(t, item, vals.name);
381 assertObjectName(t, item, vals.objectName);
382 assertIsNotServer(t, item);
383 assertIsGlobbable(t, item);
384}
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700385
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700386function assertMountedName(t, item, val) {
387 t.ok(item.mountedName, item.mountedName + ': has a mounted name');
388 t.equal(item.mountedName, val, item.mountedName + ': mounted name matches');
389}
390
391function assertObjectName(t, item, val) {
392 t.ok(item.objectName, item.mountedName + ': has an object name');
Ali Ghassemi43064312014-10-14 17:24:32 -0700393 t.equal(item.objectName, val, item.mountedName + ': object name matches');
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700394}
395
396function assertIsServer(t, item) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700397 t.equal(item.isServer, true, item.mountedName + ': is a server');
398 t.ok(item.serverInfo, item.mountedName + ': has server info');
Alex Fandriantof87d2a02015-01-27 10:42:52 -0800399 t.ok(item.serverInfo.endpoints.length > 0, item.mountedName +
400 ': has at least 1 endpoint');
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700401}
402
403function assertIsNotServer(t, item) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700404 t.equal(item.isServer, false, item.mountedName + ': is not a server');
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700405}
406
407function assertIsGlobbable(t, item) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700408 t.equal(item.isGlobbable, true, item.mountedName + ': is globbable');
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700409}
410
411function assertIsNotGlobbable(t, item) {
Ali Ghassemi43064312014-10-14 17:24:32 -0700412 t.equal(item.isGlobbable, false, item.mountedName + ': is not globbable');
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700413}
414
Ali Ghassemi11256942014-10-08 15:14:49 -0700415function assertIsImmutable(t, observable) {
416 t.ok(observable.set === undefined, 'is immutable');
417}
418
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700419/*
Alex Fandrianto4204a882014-09-19 13:34:32 -0700420 * Asserts that a ServiceTypeInfo is of predefined type of Unknown Service.
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700421 */
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700422function assertUnknownServiceTypeInfo(t, item) {
423 var typeInfo = item.serverInfo.typeInfo;
424 t.equal(typeInfo.key, 'veyron-unknown',
425 item.mountedName + ': unknown type info has the right key');
426
427 t.equal(typeInfo.typeName, 'Service',
428 item.mountedName + ': unknown type info has the type name');
429
430 t.equal(typeInfo.description, null,
431 item.mountedName + ': unknown type info does not have description');
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700432}
433
434/*
Alex Fandrianto4204a882014-09-19 13:34:32 -0700435 * Asserts that a ServiceTypeInfo is of predefined type of mounttable.
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700436 */
Ali Ghassemid94e91c2014-10-01 11:22:46 -0700437function assertMounttableServiceTypeInfo(t, item) {
438 var typeInfo = item.serverInfo.typeInfo;
439 t.equal(typeInfo.key, 'veyron-mounttable',
440 item.mountedName + ': mounttable type info has the right key');
441
442 t.equal(typeInfo.typeName, 'Mount Table',
443 item.mountedName + ': mounttable type info has the type name');
444
445 t.ok(typeInfo.description,
446 item.mountedName + ': mounttable type info has a description');
Ali Ghassemifcab3c32014-09-12 14:24:12 -0700447}
Alex Fandrianto81b31842014-10-14 09:54:02 -0700448/*
449 * Runs a test to ensure the makeRPC call terminates without error.
450 */
451function testMakeRPCNoError(args, t) {
452 namespaceService.makeRPC.apply(null, args).then(function(result) {
453 t.pass('completed without error');
454 t.end();
455 }).catch(function(err) {
Ali Ghassemi442851c2014-12-12 13:47:40 -0800456 t.end(err);
Alex Fandrianto81b31842014-10-14 09:54:02 -0700457 });
458}
459
460/*
461 * Runs a test to ensure the makeRPC call terminates with an error.
462 */
463function testMakeRPCHasError(args, t) {
464 namespaceService.makeRPC.apply(null, args).then(function(result) {
465 t.fail('should not have completed without error');
466 t.end();
467 }).catch(function(err) {
468 t.pass('correctly returned an error');
469 t.end();
470 });
Nicolas LaCasse8d22fb22015-01-22 17:26:31 -0800471}