grpc 0.13.0.pre1.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/etc/roots.pem +5114 -0
  3. data/grpc_c.32.ruby +0 -0
  4. data/grpc_c.64.ruby +0 -0
  5. data/src/ruby/bin/apis/google/protobuf/empty.rb +44 -0
  6. data/src/ruby/bin/apis/pubsub_demo.rb +256 -0
  7. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +174 -0
  8. data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +103 -0
  9. data/src/ruby/bin/grpc_ruby_interop_client +33 -0
  10. data/src/ruby/bin/grpc_ruby_interop_server +33 -0
  11. data/src/ruby/bin/interop/interop_client.rb +51 -0
  12. data/src/ruby/bin/interop/interop_server.rb +50 -0
  13. data/src/ruby/bin/math.rb +32 -0
  14. data/src/ruby/bin/math_client.rb +147 -0
  15. data/src/ruby/bin/math_server.rb +206 -0
  16. data/src/ruby/bin/math_services.rb +27 -0
  17. data/src/ruby/bin/noproto_client.rb +108 -0
  18. data/src/ruby/bin/noproto_server.rb +112 -0
  19. data/src/ruby/ext/grpc/extconf.rb +129 -0
  20. data/src/ruby/ext/grpc/rb_byte_buffer.c +70 -0
  21. data/src/ruby/ext/grpc/rb_byte_buffer.h +47 -0
  22. data/src/ruby/ext/grpc/rb_call.c +908 -0
  23. data/src/ruby/ext/grpc/rb_call.h +66 -0
  24. data/src/ruby/ext/grpc/rb_call_credentials.c +319 -0
  25. data/src/ruby/ext/grpc/rb_call_credentials.h +46 -0
  26. data/src/ruby/ext/grpc/rb_channel.c +432 -0
  27. data/src/ruby/ext/grpc/rb_channel.h +47 -0
  28. data/src/ruby/ext/grpc/rb_channel_args.c +169 -0
  29. data/src/ruby/ext/grpc/rb_channel_args.h +53 -0
  30. data/src/ruby/ext/grpc/rb_channel_credentials.c +268 -0
  31. data/src/ruby/ext/grpc/rb_channel_credentials.h +47 -0
  32. data/src/ruby/ext/grpc/rb_completion_queue.c +183 -0
  33. data/src/ruby/ext/grpc/rb_completion_queue.h +55 -0
  34. data/src/ruby/ext/grpc/rb_event_thread.c +158 -0
  35. data/src/ruby/ext/grpc/rb_event_thread.h +37 -0
  36. data/src/ruby/ext/grpc/rb_grpc.c +336 -0
  37. data/src/ruby/ext/grpc/rb_grpc.h +85 -0
  38. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +560 -0
  39. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +843 -0
  40. data/src/ruby/ext/grpc/rb_loader.c +72 -0
  41. data/src/ruby/ext/grpc/rb_loader.h +40 -0
  42. data/src/ruby/ext/grpc/rb_server.c +400 -0
  43. data/src/ruby/ext/grpc/rb_server.h +47 -0
  44. data/src/ruby/ext/grpc/rb_server_credentials.c +284 -0
  45. data/src/ruby/ext/grpc/rb_server_credentials.h +47 -0
  46. data/src/ruby/lib/grpc.rb +44 -0
  47. data/src/ruby/lib/grpc/2.0/grpc_c.bundle +0 -0
  48. data/src/ruby/lib/grpc/2.1/grpc_c.bundle +0 -0
  49. data/src/ruby/lib/grpc/2.2/grpc_c.bundle +0 -0
  50. data/src/ruby/lib/grpc/2.3/grpc_c.bundle +0 -0
  51. data/src/ruby/lib/grpc/core/time_consts.rb +71 -0
  52. data/src/ruby/lib/grpc/errors.rb +62 -0
  53. data/src/ruby/lib/grpc/generic/active_call.rb +488 -0
  54. data/src/ruby/lib/grpc/generic/bidi_call.rb +218 -0
  55. data/src/ruby/lib/grpc/generic/client_stub.rb +471 -0
  56. data/src/ruby/lib/grpc/generic/rpc_desc.rb +147 -0
  57. data/src/ruby/lib/grpc/generic/rpc_server.rb +504 -0
  58. data/src/ruby/lib/grpc/generic/service.rb +234 -0
  59. data/src/ruby/lib/grpc/grpc.rb +34 -0
  60. data/src/ruby/lib/grpc/logconfig.rb +59 -0
  61. data/src/ruby/lib/grpc/notifier.rb +60 -0
  62. data/src/ruby/lib/grpc/version.rb +33 -0
  63. data/src/ruby/pb/README.md +42 -0
  64. data/src/ruby/pb/generate_proto_ruby.sh +51 -0
  65. data/src/ruby/pb/grpc/health/checker.rb +75 -0
  66. data/src/ruby/pb/grpc/health/v1alpha/health.rb +29 -0
  67. data/src/ruby/pb/grpc/health/v1alpha/health_services.rb +28 -0
  68. data/src/ruby/pb/test/client.rb +469 -0
  69. data/src/ruby/pb/test/proto/empty.rb +15 -0
  70. data/src/ruby/pb/test/proto/messages.rb +80 -0
  71. data/src/ruby/pb/test/proto/test.rb +14 -0
  72. data/src/ruby/pb/test/proto/test_services.rb +64 -0
  73. data/src/ruby/pb/test/server.rb +253 -0
  74. data/src/ruby/spec/call_credentials_spec.rb +57 -0
  75. data/src/ruby/spec/call_spec.rb +163 -0
  76. data/src/ruby/spec/channel_credentials_spec.rb +97 -0
  77. data/src/ruby/spec/channel_spec.rb +177 -0
  78. data/src/ruby/spec/client_server_spec.rb +475 -0
  79. data/src/ruby/spec/completion_queue_spec.rb +42 -0
  80. data/src/ruby/spec/generic/active_call_spec.rb +373 -0
  81. data/src/ruby/spec/generic/client_stub_spec.rb +476 -0
  82. data/src/ruby/spec/generic/rpc_desc_spec.rb +331 -0
  83. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +138 -0
  84. data/src/ruby/spec/generic/rpc_server_spec.rb +576 -0
  85. data/src/ruby/spec/generic/service_spec.rb +345 -0
  86. data/src/ruby/spec/pb/health/checker_spec.rb +232 -0
  87. data/src/ruby/spec/server_credentials_spec.rb +94 -0
  88. data/src/ruby/spec/server_spec.rb +209 -0
  89. data/src/ruby/spec/spec_helper.rb +69 -0
  90. data/src/ruby/spec/testdata/README +1 -0
  91. data/src/ruby/spec/testdata/ca.pem +15 -0
  92. data/src/ruby/spec/testdata/server1.key +16 -0
  93. data/src/ruby/spec/testdata/server1.pem +16 -0
  94. data/src/ruby/spec/time_consts_spec.rb +89 -0
  95. metadata +319 -0
@@ -0,0 +1,94 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ require 'grpc'
31
+
32
+ def load_test_certs
33
+ test_root = File.join(File.dirname(__FILE__), 'testdata')
34
+ files = ['ca.pem', 'server1.key', 'server1.pem']
35
+ contents = files.map { |f| File.open(File.join(test_root, f)).read }
36
+ [contents[0], [{ private_key: contents[1], cert_chain: contents[2] }], false]
37
+ end
38
+
39
+ describe GRPC::Core::ServerCredentials do
40
+ Creds = GRPC::Core::ServerCredentials
41
+
42
+ describe '#new' do
43
+ it 'can be constructed from a fake CA PEM, server PEM and a server key' do
44
+ creds = Creds.new('a', [{ private_key: 'a', cert_chain: 'b' }], false)
45
+ expect(creds).to_not be_nil
46
+ end
47
+
48
+ it 'can be constructed using the test certificates' do
49
+ certs = load_test_certs
50
+ expect { Creds.new(*certs) }.not_to raise_error
51
+ end
52
+
53
+ it 'cannot be constructed without a nil key_cert pair array' do
54
+ root_cert, _, _ = load_test_certs
55
+ blk = proc do
56
+ Creds.new(root_cert, nil, false)
57
+ end
58
+ expect(&blk).to raise_error
59
+ end
60
+
61
+ it 'cannot be constructed without any key_cert pairs' do
62
+ root_cert, _, _ = load_test_certs
63
+ blk = proc do
64
+ Creds.new(root_cert, [], false)
65
+ end
66
+ expect(&blk).to raise_error
67
+ end
68
+
69
+ it 'cannot be constructed without a server cert chain' do
70
+ root_cert, server_key, _ = load_test_certs
71
+ blk = proc do
72
+ Creds.new(root_cert,
73
+ [{ server_key: server_key, cert_chain: nil }],
74
+ false)
75
+ end
76
+ expect(&blk).to raise_error
77
+ end
78
+
79
+ it 'cannot be constructed without a server key' do
80
+ root_cert, _, _ = load_test_certs
81
+ blk = proc do
82
+ Creds.new(root_cert,
83
+ [{ server_key: nil, cert_chain: cert_chain }])
84
+ end
85
+ expect(&blk).to raise_error
86
+ end
87
+
88
+ it 'can be constructed without a root_cret' do
89
+ _, cert_pairs, _ = load_test_certs
90
+ blk = proc { Creds.new(nil, cert_pairs, false) }
91
+ expect(&blk).to_not raise_error
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,209 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ require 'grpc'
31
+
32
+ def load_test_certs
33
+ test_root = File.join(File.dirname(__FILE__), 'testdata')
34
+ files = ['ca.pem', 'server1.key', 'server1.pem']
35
+ contents = files.map { |f| File.open(File.join(test_root, f)).read }
36
+ [contents[0], [{ private_key: contents[1], cert_chain: contents[2] }], false]
37
+ end
38
+
39
+ Server = GRPC::Core::Server
40
+
41
+ describe Server do
42
+ def create_test_cert
43
+ GRPC::Core::ServerCredentials.new(*load_test_certs)
44
+ end
45
+
46
+ before(:each) do
47
+ @cq = GRPC::Core::CompletionQueue.new
48
+ end
49
+
50
+ describe '#start' do
51
+ it 'runs without failing' do
52
+ blk = proc { Server.new(@cq, nil).start }
53
+ expect(&blk).to_not raise_error
54
+ end
55
+
56
+ it 'fails if the server is closed' do
57
+ s = Server.new(@cq, nil)
58
+ s.close(@cq)
59
+ expect { s.start }.to raise_error(RuntimeError)
60
+ end
61
+ end
62
+
63
+ describe '#destroy' do
64
+ it 'destroys a server ok' do
65
+ s = start_a_server
66
+ blk = proc { s.destroy(@cq) }
67
+ expect(&blk).to_not raise_error
68
+ end
69
+
70
+ it 'can be called more than once without error' do
71
+ s = start_a_server
72
+ begin
73
+ blk = proc { s.destroy(@cq) }
74
+ expect(&blk).to_not raise_error
75
+ blk.call
76
+ expect(&blk).to_not raise_error
77
+ ensure
78
+ s.close(@cq)
79
+ end
80
+ end
81
+ end
82
+
83
+ describe '#close' do
84
+ it 'closes a server ok' do
85
+ s = start_a_server
86
+ begin
87
+ blk = proc { s.close(@cq) }
88
+ expect(&blk).to_not raise_error
89
+ ensure
90
+ s.close(@cq)
91
+ end
92
+ end
93
+
94
+ it 'can be called more than once without error' do
95
+ s = start_a_server
96
+ blk = proc { s.close(@cq) }
97
+ expect(&blk).to_not raise_error
98
+ blk.call
99
+ expect(&blk).to_not raise_error
100
+ end
101
+ end
102
+
103
+ describe '#add_http_port' do
104
+ describe 'for insecure servers' do
105
+ it 'runs without failing' do
106
+ blk = proc do
107
+ s = Server.new(@cq, nil)
108
+ s.add_http2_port('localhost:0', :this_port_is_insecure)
109
+ s.close(@cq)
110
+ end
111
+ expect(&blk).to_not raise_error
112
+ end
113
+
114
+ it 'fails if the server is closed' do
115
+ s = Server.new(@cq, nil)
116
+ s.close(@cq)
117
+ blk = proc do
118
+ s.add_http2_port('localhost:0', :this_port_is_insecure)
119
+ end
120
+ expect(&blk).to raise_error(RuntimeError)
121
+ end
122
+ end
123
+
124
+ describe 'for secure servers' do
125
+ let(:cert) { create_test_cert }
126
+ it 'runs without failing' do
127
+ blk = proc do
128
+ s = Server.new(@cq, nil)
129
+ s.add_http2_port('localhost:0', cert)
130
+ s.close(@cq)
131
+ end
132
+ expect(&blk).to_not raise_error
133
+ end
134
+
135
+ it 'fails if the server is closed' do
136
+ s = Server.new(@cq, nil)
137
+ s.close(@cq)
138
+ blk = proc { s.add_http2_port('localhost:0', cert) }
139
+ expect(&blk).to raise_error(RuntimeError)
140
+ end
141
+ end
142
+ end
143
+
144
+ shared_examples '#new' do
145
+ it 'takes a completion queue with nil channel args' do
146
+ expect { Server.new(@cq, nil) }.to_not raise_error
147
+ end
148
+
149
+ it 'does not take a hash with bad keys as channel args' do
150
+ blk = construct_with_args(Object.new => 1)
151
+ expect(&blk).to raise_error TypeError
152
+ blk = construct_with_args(1 => 1)
153
+ expect(&blk).to raise_error TypeError
154
+ end
155
+
156
+ it 'does not take a hash with bad values as channel args' do
157
+ blk = construct_with_args(symbol: Object.new)
158
+ expect(&blk).to raise_error TypeError
159
+ blk = construct_with_args('1' => {})
160
+ expect(&blk).to raise_error TypeError
161
+ end
162
+
163
+ it 'can take a hash with a symbol key as channel args' do
164
+ blk = construct_with_args(a_symbol: 1)
165
+ expect(&blk).to_not raise_error
166
+ end
167
+
168
+ it 'can take a hash with a string key as channel args' do
169
+ blk = construct_with_args('a_symbol' => 1)
170
+ expect(&blk).to_not raise_error
171
+ end
172
+
173
+ it 'can take a hash with a string value as channel args' do
174
+ blk = construct_with_args(a_symbol: '1')
175
+ expect(&blk).to_not raise_error
176
+ end
177
+
178
+ it 'can take a hash with a symbol value as channel args' do
179
+ blk = construct_with_args(a_symbol: :another_symbol)
180
+ expect(&blk).to_not raise_error
181
+ end
182
+
183
+ it 'can take a hash with a numeric value as channel args' do
184
+ blk = construct_with_args(a_symbol: 1)
185
+ expect(&blk).to_not raise_error
186
+ end
187
+
188
+ it 'can take a hash with many args as channel args' do
189
+ args = Hash[127.times.collect { |x| [x.to_s, x] }]
190
+ blk = construct_with_args(args)
191
+ expect(&blk).to_not raise_error
192
+ end
193
+ end
194
+
195
+ describe '#new with an insecure channel' do
196
+ def construct_with_args(a)
197
+ proc { Server.new(@cq, a) }
198
+ end
199
+
200
+ it_behaves_like '#new'
201
+ end
202
+
203
+ def start_a_server
204
+ s = Server.new(@cq, nil)
205
+ s.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
206
+ s.start
207
+ s
208
+ end
209
+ end
@@ -0,0 +1,69 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ spec_dir = File.expand_path(File.dirname(__FILE__))
31
+ root_dir = File.expand_path(File.join(spec_dir, '..'))
32
+ lib_dir = File.expand_path(File.join(root_dir, 'lib'))
33
+
34
+ $LOAD_PATH.unshift(spec_dir)
35
+ $LOAD_PATH.unshift(lib_dir)
36
+ $LOAD_PATH.uniq!
37
+
38
+ # set up coverage
39
+ require 'simplecov'
40
+ SimpleCov.start do
41
+ add_filter 'spec'
42
+ add_filter 'bin'
43
+ SimpleCov.command_name ENV['COVERAGE_NAME']
44
+ end if ENV['COVERAGE_NAME']
45
+
46
+ require 'rspec'
47
+ require 'logging'
48
+ require 'rspec/logging_helper'
49
+
50
+ # GRPC is the general RPC module
51
+ #
52
+ # Configure its logging for fine-grained log control during test runs
53
+ module GRPC
54
+ extend Logging.globally
55
+ end
56
+ Logging.logger.root.appenders = Logging.appenders.stdout
57
+ Logging.logger.root.level = :info
58
+ Logging.logger['GRPC'].level = :info
59
+ Logging.logger['GRPC::ActiveCall'].level = :info
60
+ Logging.logger['GRPC::BidiCall'].level = :info
61
+
62
+ # Configure RSpec to capture log messages for each test. The output from the
63
+ # logs will be stored in the @log_output variable. It is a StringIO instance.
64
+ RSpec.configure do |config|
65
+ include RSpec::LoggingHelper
66
+ config.capture_log_messages # comment this out to see logs during test runs
67
+ end
68
+
69
+ RSpec::Expectations.configuration.warn_about_potential_false_positives = false
@@ -0,0 +1 @@
1
+ These are test keys *NOT* to be used in production.
@@ -0,0 +1,15 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
3
+ BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
4
+ aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAe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DDM4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1Bg
9
+ zkWF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd
10
+ 9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw
11
+ CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy
12
+ em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G
13
+ CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6
14
+ hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh
15
+ y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8
16
+ -----END CERTIFICATE-----
@@ -0,0 +1,89 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ require 'grpc'
31
+
32
+ TimeConsts = GRPC::Core::TimeConsts
33
+
34
+ describe TimeConsts do
35
+ before(:each) do
36
+ @known_consts = [:ZERO, :INFINITE_FUTURE, :INFINITE_PAST].sort
37
+ end
38
+
39
+ it 'should have all the known types' do
40
+ expect(TimeConsts.constants.collect.sort).to eq(@known_consts)
41
+ end
42
+
43
+ describe '#to_time' do
44
+ it 'converts each constant to a Time' do
45
+ m = TimeConsts
46
+ m.constants.each do |c|
47
+ expect(m.const_get(c).to_time).to be_a(Time)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ describe '#from_relative_time' do
54
+ it 'cannot handle arbitrary objects' do
55
+ expect { TimeConsts.from_relative_time(Object.new) }.to raise_error
56
+ end
57
+
58
+ it 'preserves TimeConsts' do
59
+ m = TimeConsts
60
+ m.constants.each do |c|
61
+ const = m.const_get(c)
62
+ expect(TimeConsts.from_relative_time(const)).to be(const)
63
+ end
64
+ end
65
+
66
+ it 'converts 0 to TimeConsts::ZERO' do
67
+ expect(TimeConsts.from_relative_time(0)).to eq(TimeConsts::ZERO)
68
+ end
69
+
70
+ it 'converts nil to TimeConsts::ZERO' do
71
+ expect(TimeConsts.from_relative_time(nil)).to eq(TimeConsts::ZERO)
72
+ end
73
+
74
+ it 'converts negative values to TimeConsts::INFINITE_FUTURE' do
75
+ [-1, -3.2, -1e6].each do |t|
76
+ y = TimeConsts.from_relative_time(t)
77
+ expect(y).to eq(TimeConsts::INFINITE_FUTURE)
78
+ end
79
+ end
80
+
81
+ it 'converts a positive value to an absolute time' do
82
+ epsilon = 1
83
+ [1, 3.2, 1e6].each do |t|
84
+ want = Time.now + t
85
+ abs = TimeConsts.from_relative_time(t)
86
+ expect(abs.to_f).to be_within(epsilon).of(want.to_f)
87
+ end
88
+ end
89
+ end