blob: fa06ad4e4d45d18564e4504cdcc07a3b06abd07a [file] [log] [blame]
murgatroid99749666e2015-01-12 18:25:58 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
murgatroid99749666e2015-01-12 18:25:58 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
murgatroid99dca966d2015-02-19 14:37:18 -080034'use strict';
35
murgatroid99e5061512015-01-12 18:14:35 -080036var assert = require('assert');
37var grpc = require('bindings')('grpc.node');
38
39/**
40 * List of all status names
41 * @const
42 * @type {Array.<string>}
43 */
44var statusNames = [
45 'OK',
46 'CANCELLED',
47 'UNKNOWN',
48 'INVALID_ARGUMENT',
49 'DEADLINE_EXCEEDED',
50 'NOT_FOUND',
51 'ALREADY_EXISTS',
52 'PERMISSION_DENIED',
53 'UNAUTHENTICATED',
54 'RESOURCE_EXHAUSTED',
55 'FAILED_PRECONDITION',
56 'ABORTED',
57 'OUT_OF_RANGE',
58 'UNIMPLEMENTED',
59 'INTERNAL',
60 'UNAVAILABLE',
61 'DATA_LOSS'
62];
63
64/**
65 * List of all call error names
66 * @const
67 * @type {Array.<string>}
68 */
69var callErrorNames = [
70 'OK',
71 'ERROR',
72 'NOT_ON_SERVER',
73 'NOT_ON_CLIENT',
74 'ALREADY_INVOKED',
75 'NOT_INVOKED',
76 'ALREADY_FINISHED',
77 'TOO_MANY_OPERATIONS',
78 'INVALID_FLAGS'
79];
80
murgatroid9999e21042015-08-14 10:35:43 -070081/**
82 * List of all propagate flag names
83 * @const
84 * @type {Array.<string>}
85 */
86var propagateFlagNames = [
87 'DEADLINE',
88 'CENSUS_STATS_CONTEXT',
89 'CENSUS_TRACING_CONTEXT',
murgatroid990b094572015-08-14 10:48:45 -070090 'CANCELLATION',
91 'DEFAULTS'
murgatroid9999e21042015-08-14 10:35:43 -070092];
murgatroid99c04c03c2015-08-14 11:02:32 -070093/*
murgatroid99c7f4d4f2015-07-28 15:18:57 -070094 * List of all connectivity state names
95 * @const
96 * @type {Array.<string>}
97 */
98var connectivityStateNames = [
99 'IDLE',
100 'CONNECTING',
101 'READY',
102 'TRANSIENT_FAILURE',
103 'FATAL_FAILURE'
104];
murgatroid9999e21042015-08-14 10:35:43 -0700105
murgatroid99e5061512015-01-12 18:14:35 -0800106describe('constants', function() {
107 it('should have all of the status constants', function() {
108 for (var i = 0; i < statusNames.length; i++) {
109 assert(grpc.status.hasOwnProperty(statusNames[i]),
110 'status missing: ' + statusNames[i]);
111 }
112 });
113 it('should have all of the call errors', function() {
114 for (var i = 0; i < callErrorNames.length; i++) {
115 assert(grpc.callError.hasOwnProperty(callErrorNames[i]),
116 'call error missing: ' + callErrorNames[i]);
117 }
118 });
murgatroid9999e21042015-08-14 10:35:43 -0700119 it('should have all of the propagate flags', function() {
120 for (var i = 0; i < propagateFlagNames.length; i++) {
121 assert(grpc.propagate.hasOwnProperty(propagateFlagNames[i]),
122 'call error missing: ' + propagateFlagNames[i]);
123 }
124 });
murgatroid99c7f4d4f2015-07-28 15:18:57 -0700125 it('should have all of the connectivity states', function() {
126 for (var i = 0; i < connectivityStateNames.length; i++) {
127 assert(grpc.connectivityState.hasOwnProperty(connectivityStateNames[i]),
128 'connectivity status missing: ' + connectivityStateNames[i]);
129 }
130 });
Craig Tillerce5021b2015-02-18 09:25:21 -0800131});