blob: b9f8958da9f9ea4c398d80619bc2d2cbee2c8081 [file] [log] [blame]
murgatroid99e5061512015-01-12 18:14:35 -08001var assert = require('assert');
2var grpc = require('bindings')('grpc.node');
3
4/**
5 * List of all status names
6 * @const
7 * @type {Array.<string>}
8 */
9var statusNames = [
10 'OK',
11 'CANCELLED',
12 'UNKNOWN',
13 'INVALID_ARGUMENT',
14 'DEADLINE_EXCEEDED',
15 'NOT_FOUND',
16 'ALREADY_EXISTS',
17 'PERMISSION_DENIED',
18 'UNAUTHENTICATED',
19 'RESOURCE_EXHAUSTED',
20 'FAILED_PRECONDITION',
21 'ABORTED',
22 'OUT_OF_RANGE',
23 'UNIMPLEMENTED',
24 'INTERNAL',
25 'UNAVAILABLE',
26 'DATA_LOSS'
27];
28
29/**
30 * List of all call error names
31 * @const
32 * @type {Array.<string>}
33 */
34var callErrorNames = [
35 'OK',
36 'ERROR',
37 'NOT_ON_SERVER',
38 'NOT_ON_CLIENT',
39 'ALREADY_INVOKED',
40 'NOT_INVOKED',
41 'ALREADY_FINISHED',
42 'TOO_MANY_OPERATIONS',
43 'INVALID_FLAGS'
44];
45
46/**
47 * List of all op error names
48 * @const
49 * @type {Array.<string>}
50 */
51var opErrorNames = [
52 'OK',
53 'ERROR'
54];
55
56/**
57 * List of all completion type names
58 * @const
59 * @type {Array.<string>}
60 */
61var completionTypeNames = [
62 'QUEUE_SHUTDOWN',
63 'READ',
64 'INVOKE_ACCEPTED',
65 'WRITE_ACCEPTED',
66 'FINISH_ACCEPTED',
67 'CLIENT_METADATA_READ',
68 'FINISHED',
69 'SERVER_RPC_NEW'
70];
71
72describe('constants', function() {
73 it('should have all of the status constants', function() {
74 for (var i = 0; i < statusNames.length; i++) {
75 assert(grpc.status.hasOwnProperty(statusNames[i]),
76 'status missing: ' + statusNames[i]);
77 }
78 });
79 it('should have all of the call errors', function() {
80 for (var i = 0; i < callErrorNames.length; i++) {
81 assert(grpc.callError.hasOwnProperty(callErrorNames[i]),
82 'call error missing: ' + callErrorNames[i]);
83 }
84 });
85 it('should have all of the op errors', function() {
86 for (var i = 0; i < opErrorNames.length; i++) {
87 assert(grpc.opError.hasOwnProperty(opErrorNames[i]),
88 'op error missing: ' + opErrorNames[i]);
89 }
90 });
91 it('should have all of the completion types', function() {
92 for (var i = 0; i < completionTypeNames.length; i++) {
93 assert(grpc.completionType.hasOwnProperty(completionTypeNames[i]),
94 'completion type missing: ' + completionTypeNames[i]);
95 }
96 });
97});