riakpb 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/Rakefile +44 -76
- data/lib/benchmark/bench_stocks.rb +26 -0
- data/lib/riakpb/client/rpc.rb +7 -7
- data/lib/riakpb/version.rb +3 -0
- data/lib/riakpb.rb +0 -2
- data/load_stocks.rb +10 -2
- data/riak-pbclient.tmproj +157 -0
- data/riakpb.gemspec +28 -0
- data/spec/riak/bucket_spec.rb +105 -0
- data/spec/riak/client_spec.rb +199 -0
- data/spec/riak/content_spec.rb +74 -0
- data/spec/riak/key_spec.rb +54 -0
- data/spec/riak/map_reduce_spec.rb +327 -0
- data/spec/riak/rpc_spec.rb +4 -0
- metadata +82 -33
- data/History.txt +0 -4
- data/Manifest.txt +0 -30
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-cfs
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
riakpb (0.2.3)
|
5
|
+
activesupport (~> 3.0.0)
|
6
|
+
ruby_protobuf (~> 0.4.8)
|
7
|
+
yard (~> 0.6.4)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (3.0.3)
|
13
|
+
diff-lcs (1.1.2)
|
14
|
+
i18n (0.5.0)
|
15
|
+
rspec (2.3.0)
|
16
|
+
rspec-core (~> 2.3.0)
|
17
|
+
rspec-expectations (~> 2.3.0)
|
18
|
+
rspec-mocks (~> 2.3.0)
|
19
|
+
rspec-core (2.3.1)
|
20
|
+
rspec-expectations (2.3.0)
|
21
|
+
diff-lcs (~> 1.1.2)
|
22
|
+
rspec-mocks (2.3.0)
|
23
|
+
ruby_protobuf (0.4.8)
|
24
|
+
yard (0.6.4)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
activesupport (~> 3.0.0)
|
31
|
+
i18n (~> 0.5.0)
|
32
|
+
riakpb!
|
33
|
+
rspec (~> 2.3.0)
|
34
|
+
ruby_protobuf (~> 0.4.8)
|
35
|
+
yard (~> 0.6.4)
|
data/Rakefile
CHANGED
@@ -1,76 +1,44 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
files
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
File.open("#{gemspec.name}.gemspec", 'w'){|f| f.write gemspec.to_ruby }
|
46
|
-
end
|
47
|
-
|
48
|
-
desc %{Release the gem to RubyGems.org}
|
49
|
-
task :release => :gem do
|
50
|
-
"gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
51
|
-
end
|
52
|
-
|
53
|
-
require 'rspec/core'
|
54
|
-
require 'rspec/core/rake_task'
|
55
|
-
|
56
|
-
desc "Run Unit Specs Only"
|
57
|
-
Rspec::Core::RakeTask.new(:spec) do |spec|
|
58
|
-
spec.pattern = "spec/riakpb/**/*_spec.rb"
|
59
|
-
end
|
60
|
-
|
61
|
-
namespace :spec do
|
62
|
-
desc "Run Integration Specs Only"
|
63
|
-
Rspec::Core::RakeTask.new(:integration) do |spec|
|
64
|
-
spec.pattern = "spec/integration/**/*_spec.rb"
|
65
|
-
end
|
66
|
-
|
67
|
-
desc "Run All Specs"
|
68
|
-
Rspec::Core::RakeTask.new(:all) do |spec|
|
69
|
-
spec.pattern = Rake::FileList["spec/**/*_spec.rb"]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
74
|
-
# remove_task :default
|
75
|
-
# task :default => [:spec, :features]
|
76
|
-
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'rspec/core'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
|
9
|
+
# task :release => :spec
|
10
|
+
|
11
|
+
desc "Run Specs"
|
12
|
+
Rspec::Core::RakeTask.new(:spec) do |spec|
|
13
|
+
spec.pattern = "spec/**/*_spec.rb"
|
14
|
+
spec.verbose = true
|
15
|
+
spec.rspec_opts = ['--color']
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'yard'
|
19
|
+
|
20
|
+
desc "Generate YARD docs"
|
21
|
+
YARD::Rake::YardocTask.new(:yard) do |t|
|
22
|
+
t.files += ['lib/**/*.rb']
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Run Unit Specs Only"
|
26
|
+
Rspec::Core::RakeTask.new(:spec) do |spec|
|
27
|
+
spec.pattern = "spec/riakpb/**/*_spec.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :spec do
|
31
|
+
desc "Run Integration Specs Only"
|
32
|
+
Rspec::Core::RakeTask.new(:integration) do |spec|
|
33
|
+
spec.pattern = "spec/integration/**/*_spec.rb"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Run All Specs"
|
37
|
+
Rspec::Core::RakeTask.new(:all) do |spec|
|
38
|
+
spec.pattern = Rake::FileList["spec/**/*_spec.rb"]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
43
|
+
# remove_task :default
|
44
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
require 'csv'
|
7
|
+
require 'benchmark'
|
8
|
+
|
9
|
+
@noisy = ARGV.grep("-q").none?
|
10
|
+
|
11
|
+
Benchmark.bmbm do |x|
|
12
|
+
x.report do
|
13
|
+
|
14
|
+
client = Riakpb::Client.new
|
15
|
+
bucket = client["goog"]
|
16
|
+
|
17
|
+
CSV.foreach('goog.csv', :headers => true) do |row|
|
18
|
+
@noisy && puts(row.first[1].to_s)
|
19
|
+
|
20
|
+
key = bucket[row.first[1].to_s]
|
21
|
+
key.content.value = Hash[row.to_a]
|
22
|
+
key.save
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/riakpb/client/rpc.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Special thanks to:
|
2
2
|
#
|
3
3
|
# - Radar in #ruby-lang
|
4
|
-
# - xnotdotorg / arilerner[at]gmail.com -
|
4
|
+
# - xnotdotorg / arilerner[at]gmail.com -
|
5
5
|
# http://blog.xnot.org/2008/11/16/communicating-from-ruby-to-erlang/
|
6
6
|
#
|
7
7
|
require 'socket'
|
@@ -67,14 +67,14 @@ module Riakpb
|
|
67
67
|
@set_c_id_req ||= assemble_request( Util::MessageCode::SET_CLIENT_ID_REQUEST,
|
68
68
|
@set_client_id.serialize_to_string)
|
69
69
|
|
70
|
-
socket.
|
71
|
-
set_c_id_resp = socket.
|
70
|
+
socket.write(@set_c_id_req)
|
71
|
+
set_c_id_resp = socket.sysread(@limit)
|
72
72
|
|
73
73
|
resp_code, resp_msg = decode_message(set_c_id_resp)
|
74
74
|
|
75
75
|
return(resp_code == Util::MessageCode::SET_CLIENT_ID_RESPONSE)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
# Sends the request to the riak node
|
79
79
|
# @param [Fixnum] mc The message code that identifies the request
|
80
80
|
# @param [Protobuf::Message] pb_msg The protobuf message, if applicable, for the message code
|
@@ -93,8 +93,8 @@ module Riakpb
|
|
93
93
|
@req_message = assemble_request mc
|
94
94
|
end
|
95
95
|
|
96
|
-
socket.
|
97
|
-
self.parse_response socket.
|
96
|
+
socket.write(@req_message)
|
97
|
+
self.parse_response socket.sysread(@limit)
|
98
98
|
|
99
99
|
end while(false == (@response[:done] rescue true))
|
100
100
|
|
@@ -126,7 +126,7 @@ module Riakpb
|
|
126
126
|
raise FailedExchange.new(MC_RESPONSE_FOR[@req_message_code], @resp_message_codes, response_chunk, "failed_request")
|
127
127
|
end
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
if response_chunk.size > 0
|
131
131
|
@response.parse_from_string response_chunk
|
132
132
|
end
|
data/lib/riakpb.rb
CHANGED
data/load_stocks.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems' if RUBY_VERSION < '1.9'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
|
2
6
|
require 'csv'
|
7
|
+
require 'benchmark'
|
8
|
+
|
9
|
+
@noisy = ARGV.grep("-q").none?
|
3
10
|
|
4
11
|
client = Riakpb::Client.new
|
5
12
|
bucket = client["goog"]
|
6
13
|
|
7
14
|
CSV.foreach('goog.csv', :headers => true) do |row|
|
8
|
-
puts
|
15
|
+
@noisy && puts(row.first[1].to_s)
|
16
|
+
|
9
17
|
key = bucket[row.first[1].to_s]
|
10
18
|
key.content.value = Hash[row.to_a]
|
11
19
|
key.save
|
@@ -0,0 +1,157 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>currentDocument</key>
|
6
|
+
<string>lib/riakpb/client/rpc.rb</string>
|
7
|
+
<key>documents</key>
|
8
|
+
<array>
|
9
|
+
<dict>
|
10
|
+
<key>expanded</key>
|
11
|
+
<true/>
|
12
|
+
<key>name</key>
|
13
|
+
<string>riak-pbclient</string>
|
14
|
+
<key>regexFileFilter</key>
|
15
|
+
<string>!.*(\.DS_Store)</string>
|
16
|
+
<key>regexFolderFilter</key>
|
17
|
+
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
18
|
+
<key>selected</key>
|
19
|
+
<true/>
|
20
|
+
<key>sourceDirectory</key>
|
21
|
+
<string></string>
|
22
|
+
</dict>
|
23
|
+
</array>
|
24
|
+
<key>fileHierarchyDrawerWidth</key>
|
25
|
+
<integer>200</integer>
|
26
|
+
<key>metaData</key>
|
27
|
+
<dict>
|
28
|
+
<key>.rspec</key>
|
29
|
+
<dict>
|
30
|
+
<key>caret</key>
|
31
|
+
<dict>
|
32
|
+
<key>column</key>
|
33
|
+
<integer>0</integer>
|
34
|
+
<key>line</key>
|
35
|
+
<integer>1</integer>
|
36
|
+
</dict>
|
37
|
+
<key>firstVisibleColumn</key>
|
38
|
+
<integer>0</integer>
|
39
|
+
<key>firstVisibleLine</key>
|
40
|
+
<integer>0</integer>
|
41
|
+
</dict>
|
42
|
+
<key>Gemfile</key>
|
43
|
+
<dict>
|
44
|
+
<key>caret</key>
|
45
|
+
<dict>
|
46
|
+
<key>column</key>
|
47
|
+
<integer>0</integer>
|
48
|
+
<key>line</key>
|
49
|
+
<integer>0</integer>
|
50
|
+
</dict>
|
51
|
+
<key>firstVisibleColumn</key>
|
52
|
+
<integer>0</integer>
|
53
|
+
<key>firstVisibleLine</key>
|
54
|
+
<integer>0</integer>
|
55
|
+
</dict>
|
56
|
+
<key>Rakefile</key>
|
57
|
+
<dict>
|
58
|
+
<key>caret</key>
|
59
|
+
<dict>
|
60
|
+
<key>column</key>
|
61
|
+
<integer>0</integer>
|
62
|
+
<key>line</key>
|
63
|
+
<integer>23</integer>
|
64
|
+
</dict>
|
65
|
+
<key>firstVisibleColumn</key>
|
66
|
+
<integer>0</integer>
|
67
|
+
<key>firstVisibleLine</key>
|
68
|
+
<integer>0</integer>
|
69
|
+
</dict>
|
70
|
+
<key>lib/riakpb.rb</key>
|
71
|
+
<dict>
|
72
|
+
<key>caret</key>
|
73
|
+
<dict>
|
74
|
+
<key>column</key>
|
75
|
+
<integer>13</integer>
|
76
|
+
<key>line</key>
|
77
|
+
<integer>10</integer>
|
78
|
+
</dict>
|
79
|
+
<key>firstVisibleColumn</key>
|
80
|
+
<integer>0</integer>
|
81
|
+
<key>firstVisibleLine</key>
|
82
|
+
<integer>0</integer>
|
83
|
+
</dict>
|
84
|
+
<key>lib/riakpb/client/rpc.rb</key>
|
85
|
+
<dict>
|
86
|
+
<key>caret</key>
|
87
|
+
<dict>
|
88
|
+
<key>column</key>
|
89
|
+
<integer>79</integer>
|
90
|
+
<key>line</key>
|
91
|
+
<integer>64</integer>
|
92
|
+
</dict>
|
93
|
+
<key>firstVisibleColumn</key>
|
94
|
+
<integer>0</integer>
|
95
|
+
<key>firstVisibleLine</key>
|
96
|
+
<integer>0</integer>
|
97
|
+
</dict>
|
98
|
+
<key>load_stocks.rb</key>
|
99
|
+
<dict>
|
100
|
+
<key>caret</key>
|
101
|
+
<dict>
|
102
|
+
<key>column</key>
|
103
|
+
<integer>0</integer>
|
104
|
+
<key>line</key>
|
105
|
+
<integer>20</integer>
|
106
|
+
</dict>
|
107
|
+
<key>firstVisibleColumn</key>
|
108
|
+
<integer>0</integer>
|
109
|
+
<key>firstVisibleLine</key>
|
110
|
+
<integer>0</integer>
|
111
|
+
</dict>
|
112
|
+
<key>riak-pbclient.tmproj</key>
|
113
|
+
<dict>
|
114
|
+
<key>caret</key>
|
115
|
+
<dict>
|
116
|
+
<key>column</key>
|
117
|
+
<integer>0</integer>
|
118
|
+
<key>line</key>
|
119
|
+
<integer>0</integer>
|
120
|
+
</dict>
|
121
|
+
<key>firstVisibleColumn</key>
|
122
|
+
<integer>0</integer>
|
123
|
+
<key>firstVisibleLine</key>
|
124
|
+
<integer>0</integer>
|
125
|
+
</dict>
|
126
|
+
<key>riakpb.gemspec</key>
|
127
|
+
<dict>
|
128
|
+
<key>caret</key>
|
129
|
+
<dict>
|
130
|
+
<key>column</key>
|
131
|
+
<integer>0</integer>
|
132
|
+
<key>line</key>
|
133
|
+
<integer>28</integer>
|
134
|
+
</dict>
|
135
|
+
<key>firstVisibleColumn</key>
|
136
|
+
<integer>0</integer>
|
137
|
+
<key>firstVisibleLine</key>
|
138
|
+
<integer>0</integer>
|
139
|
+
</dict>
|
140
|
+
</dict>
|
141
|
+
<key>openDocuments</key>
|
142
|
+
<array>
|
143
|
+
<string>Rakefile</string>
|
144
|
+
<string>riakpb.gemspec</string>
|
145
|
+
<string>load_stocks.rb</string>
|
146
|
+
<string>lib/riakpb.rb</string>
|
147
|
+
<string>lib/riakpb/client/rpc.rb</string>
|
148
|
+
<string>Gemfile</string>
|
149
|
+
<string>.rspec</string>
|
150
|
+
<string>riak-pbclient.tmproj</string>
|
151
|
+
</array>
|
152
|
+
<key>showFileHierarchyDrawer</key>
|
153
|
+
<true/>
|
154
|
+
<key>windowFrame</key>
|
155
|
+
<string>{{61, 282}, {1246, 746}}</string>
|
156
|
+
</dict>
|
157
|
+
</plist>
|
data/riakpb.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "riakpb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "riakpb"
|
7
|
+
s.version = Riakpb::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Scott Gonyea"]
|
10
|
+
s.email = ["me@sgonyea.com"]
|
11
|
+
s.homepage = %q{http://github.com/sgonyea/riak-pbclient}
|
12
|
+
s.summary = %q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.}
|
13
|
+
s.description = %q{riakpb is an all-ruby protocol buffer client for Riak--the distributed database by Basho.}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'activesupport', '~> 3.0.0'
|
22
|
+
s.add_dependency 'ruby_protobuf', '~> 0.4.8'
|
23
|
+
|
24
|
+
s.add_dependency 'yard', '~> 0.6.4'
|
25
|
+
|
26
|
+
s.add_development_dependency 'rspec', '~> 2.3.0'
|
27
|
+
s.add_development_dependency 'i18n', '~> 0.5.0'
|
28
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Riakpb::Bucket do
|
4
|
+
describe "when directly initializing" do
|
5
|
+
before :each do
|
6
|
+
@client = Riakpb::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should default with the client and name, and empty n_val or allow_mult" do
|
10
|
+
bucket = Riakpb::Bucket.new(@client, "test")
|
11
|
+
bucket.client.should == @client
|
12
|
+
bucket.name.should == "test"
|
13
|
+
bucket.n_val.should == nil
|
14
|
+
bucket.allow_mult.should == nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should correctly accept an n_val" do
|
18
|
+
bucket = Riakpb::Bucket.new(@client, "test")
|
19
|
+
bucket.n_val = 5
|
20
|
+
bucket.n_val.should be_kind_of(Fixnum)
|
21
|
+
lambda { bucket.n_val="5" }.should raise_error(ArgumentError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should correctly accept an allow_mult" do
|
25
|
+
bucket = Riakpb::Bucket.new(@client, "test")
|
26
|
+
bucket.allow_mult = true
|
27
|
+
bucket.allow_mult.should be_kind_of(TrueClass)
|
28
|
+
bucket.allow_mult = false
|
29
|
+
bucket.allow_mult.should be_kind_of(FalseClass)
|
30
|
+
lambda { bucket.allow_mult="no" }.should raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
end # describe "when directly initializing"
|
33
|
+
|
34
|
+
describe "when initialized from the Client" do
|
35
|
+
before :each do
|
36
|
+
@client = Riakpb::Client.new
|
37
|
+
@client.rpc.stub!(:request).and_return(nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have set the properties" do
|
41
|
+
@client.rpc.stub!(:request).with(
|
42
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
43
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
44
|
+
).and_return(
|
45
|
+
Riakpb::RpbGetBucketResp.new(
|
46
|
+
{ :props => {
|
47
|
+
:allow_mult => false,
|
48
|
+
:n_val => 3
|
49
|
+
}
|
50
|
+
}
|
51
|
+
))
|
52
|
+
bucket = @client["goog"]
|
53
|
+
bucket.should be_kind_of(Riakpb::Bucket)
|
54
|
+
bucket.client.should == @client
|
55
|
+
bucket.name.should == "goog"
|
56
|
+
bucket.n_val.should == 3
|
57
|
+
bucket.allow_mult.should == false
|
58
|
+
end
|
59
|
+
end # describe "when initialized from the Client"
|
60
|
+
|
61
|
+
describe "key retrieval" do
|
62
|
+
before :each do
|
63
|
+
@client = Riakpb::Client.new
|
64
|
+
@client.rpc.stub!(:request).with(
|
65
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
66
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
67
|
+
).and_return(
|
68
|
+
Riakpb::RpbGetBucketResp.new(
|
69
|
+
{ :props => {
|
70
|
+
:allow_mult => false,
|
71
|
+
:n_val => 3
|
72
|
+
}
|
73
|
+
}
|
74
|
+
))
|
75
|
+
@bucket = @client["goog"]
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should list the keys within the bucket" do
|
79
|
+
@client.rpc.stub!(:request).with(
|
80
|
+
Riakpb::Util::MessageCode::LIST_KEYS_REQUEST,
|
81
|
+
Riakpb::RpbListKeysReq.new(:bucket => "goog")
|
82
|
+
).and_return(
|
83
|
+
Riakpb::RpbListKeysResp.new(
|
84
|
+
{ :keys => ["2010-04-12", "2008-01-10", "2006-06-06"],
|
85
|
+
:done => true
|
86
|
+
}
|
87
|
+
))
|
88
|
+
@bucket.keys.should be_kind_of(Protobuf::Field::FieldArray)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return a key, when requested" do
|
92
|
+
@client.rpc.stub!(:request).with(
|
93
|
+
Riakpb::Util::MessageCode::GET_REQUEST,
|
94
|
+
Riakpb::RpbGetReq.new(:bucket => "goog", :key => "2010-04-12", :r => nil)
|
95
|
+
).and_return(
|
96
|
+
Riakpb::RpbGetResp.new(
|
97
|
+
{ :content => [],
|
98
|
+
:vclock => ""
|
99
|
+
}
|
100
|
+
))
|
101
|
+
@bucket["2010-04-12"].should be_kind_of(Riakpb::Key)
|
102
|
+
end
|
103
|
+
end # describe "key retrieval"
|
104
|
+
|
105
|
+
end # Riakpb::Client
|