stark 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_server.rb CHANGED
@@ -33,9 +33,10 @@ class TestServer < Test::Unit::TestCase
33
33
  @last_list = nil
34
34
  @last_status = nil
35
35
  @n = n
36
+ @user_status = nil
36
37
  end
37
38
 
38
- attr_accessor :last_map, :last_list, :last_status
39
+ attr_accessor :last_map, :last_list, :last_status, :user_status
39
40
 
40
41
  def store(obj)
41
42
  @users[obj.uid] = obj
@@ -64,6 +65,19 @@ class TestServer < Test::Unit::TestCase
64
65
  def make_bitcoins
65
66
  sleep 2
66
67
  end
68
+
69
+ def add(a,b)
70
+ a + b
71
+ end
72
+
73
+ def set_user_status(s)
74
+ @user_status = s
75
+ end
76
+
77
+ attr_accessor :user_relationship
78
+ def set_user_relationship(rel)
79
+ @user_relationship = rel
80
+ end
67
81
  end
68
82
 
69
83
  def test_store_and_retrieve
@@ -212,4 +226,94 @@ class TestServer < Test::Unit::TestCase
212
226
 
213
227
  st.join
214
228
  end
229
+
230
+ def test_2args
231
+ st = Thread.new do
232
+ @server.process @server_p, @server_p
233
+ end
234
+
235
+ assert_equal 7, @client.add(3, 4)
236
+
237
+ st.join
238
+ end
239
+
240
+ def test_read_struct_in_a_struct
241
+ st = Thread.new do
242
+ @server.process @server_p, @server_p
243
+ end
244
+
245
+ prof = @n::UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
246
+ stat = @n::UserStatus.new 'profile' => prof, 'active' => true
247
+
248
+ @handler.user_status = stat
249
+
250
+ status = @client.user_status
251
+
252
+ assert_equal true, status.active
253
+
254
+ prof = status.profile
255
+
256
+ assert_equal 0, prof.uid
257
+ assert_equal "root", prof.name
258
+ assert_equal "god", prof.blurb
259
+
260
+ st.join
261
+ end
262
+
263
+ def test_write_struct_in_a_struct
264
+ st = Thread.new do
265
+ @server.process @server_p, @server_p
266
+ end
267
+
268
+ prof = @n::UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
269
+ stat = @n::UserStatus.new 'profile' => prof, 'active' => true
270
+
271
+ @client.set_user_status stat
272
+
273
+ status = @handler.user_status
274
+
275
+ assert_equal true, status.active
276
+
277
+ prof = status.profile
278
+
279
+ assert_equal 0, prof.uid
280
+ assert_equal "root", prof.name
281
+ assert_equal "god", prof.blurb
282
+
283
+ st.join
284
+ end
285
+
286
+ def test_read_enum_in_struct
287
+ st = Thread.new do
288
+ @server.process @server_p, @server_p
289
+ end
290
+
291
+ stat = @n::UserRelationship.new 'user' => 0, 'status' => :ITS_COMPLICATED
292
+
293
+ @handler.user_relationship = stat
294
+
295
+ rel = @client.user_relationship
296
+
297
+ assert_equal 0, rel.user
298
+ assert_equal :ITS_COMPLICATED, rel.status
299
+
300
+ st.join
301
+ end
302
+
303
+ def test_write_enum_in_struct
304
+ st = Thread.new do
305
+ @server.process @server_p, @server_p
306
+ end
307
+
308
+ stat = @n::UserRelationship.new 'user' => 0, 'status' => :ITS_COMPLICATED
309
+
310
+ @client.set_user_relationship stat
311
+
312
+ rel = @handler.user_relationship
313
+
314
+ assert_equal 0, rel.user
315
+ assert_equal :ITS_COMPLICATED, rel.status
316
+
317
+ st.join
318
+ end
215
319
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-03 00:00:00.000000000 Z
12
+ date: 2013-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thrift
@@ -91,9 +91,11 @@ files:
91
91
  - lib/stark/thrift.kpeg
92
92
  - stark.gemspec
93
93
  - test/ThriftSpec.thrift
94
+ - test/blah.thrift
94
95
  - test/gen-rb/profile_constants.rb
95
96
  - test/gen-rb/profile_types.rb
96
97
  - test/gen-rb/user_storage.rb
98
+ - test/include_blah.thrift
97
99
  - test/leg.rb
98
100
  - test/legacy_profile/profile_constants.rb
99
101
  - test/legacy_profile/profile_types.rb
@@ -101,6 +103,7 @@ files:
101
103
  - test/profile.thrift
102
104
  - test/test_client.rb
103
105
  - test/test_parser.rb
106
+ - test/test_ruby.rb
104
107
  - test/test_server.rb
105
108
  - .gemtest
106
109
  homepage: http://github.com/evanphx/stark
@@ -132,4 +135,5 @@ summary: Optimized thrift bindings for ruby
132
135
  test_files:
133
136
  - test/test_client.rb
134
137
  - test/test_parser.rb
138
+ - test/test_ruby.rb
135
139
  - test/test_server.rb