OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * |
| 3 * Copyright 2015-2016, Google Inc. |
| 4 * 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 |
| 34 'use strict'; |
| 35 |
| 36 var assert = require('assert'); |
| 37 var grpc = require('../src/grpc_extension'); |
| 38 |
| 39 /** |
| 40 * List of all status names |
| 41 * @const |
| 42 * @type {Array.<string>} |
| 43 */ |
| 44 var 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 */ |
| 69 var 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 |
| 81 /** |
| 82 * List of all propagate flag names |
| 83 * @const |
| 84 * @type {Array.<string>} |
| 85 */ |
| 86 var propagateFlagNames = [ |
| 87 'DEADLINE', |
| 88 'CENSUS_STATS_CONTEXT', |
| 89 'CENSUS_TRACING_CONTEXT', |
| 90 'CANCELLATION', |
| 91 'DEFAULTS' |
| 92 ]; |
| 93 /* |
| 94 * List of all connectivity state names |
| 95 * @const |
| 96 * @type {Array.<string>} |
| 97 */ |
| 98 var connectivityStateNames = [ |
| 99 'IDLE', |
| 100 'CONNECTING', |
| 101 'READY', |
| 102 'TRANSIENT_FAILURE', |
| 103 'FATAL_FAILURE' |
| 104 ]; |
| 105 |
| 106 describe('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 }); |
| 119 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 }); |
| 125 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 }); |
| 131 }); |
OLD | NEW |