riakpb 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -23
- data/Rakefile +3 -3
- data/lib/riak/bucket.rb +23 -23
- data/lib/riak/client/rpc.rb +14 -12
- data/lib/riak/client.rb +59 -73
- data/lib/riak/client_pb.rb +1 -1
- data/lib/riak/{riak_content.rb → content.rb} +125 -70
- data/lib/riak/failed_exchange.rb +2 -2
- data/lib/riak/failed_request.rb +3 -3
- data/lib/riak/key.rb +38 -38
- data/lib/riak/locale/en.yml +3 -3
- data/lib/riak/map_reduce.rb +6 -6
- data/lib/riak/sibling_error.rb +3 -3
- data/lib/riak/util/decode.rb +1 -1
- data/lib/riak/util/encode.rb +2 -2
- data/lib/riak/util/message_code.rb +9 -9
- data/lib/riak/util/translation.rb +1 -1
- data/lib/riak.rb +3 -3
- data/load_stocks.rb +1 -1
- data/spec/riak/bucket_spec.rb +22 -22
- data/spec/riak/client_spec.rb +31 -31
- data/spec/riak/{riak_content_spec.rb → content_spec.rb} +17 -18
- data/spec/riak/key_spec.rb +16 -16
- data/spec/riak/map_reduce_spec.rb +30 -30
- data/spec/riak/rpc_spec.rb +2 -2
- metadata +9 -10
- data/riakpb.gemspec +0 -37
data/lib/riak/util/encode.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'riak'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Riakpb
|
4
4
|
module Util
|
5
5
|
|
6
6
|
module Encode
|
7
7
|
|
8
|
-
# Construct a Request Message for
|
8
|
+
# Construct a Request Message for Riakpb, which adheres to the following structure:
|
9
9
|
#
|
10
10
|
# 00 00 00 07 09 0A 01 62 12 01 6B
|
11
11
|
# |----Len---|MC|----Message-----|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Riakpb
|
2
2
|
module Util
|
3
3
|
module MessageCode
|
4
4
|
ERROR_RESPONSE = 0
|
@@ -56,17 +56,17 @@ module Riak
|
|
56
56
|
|
57
57
|
RESPONSE_CLASS_FOR = {
|
58
58
|
PING_REQUEST => nil,
|
59
|
-
GET_CLIENT_ID_REQUEST =>
|
59
|
+
GET_CLIENT_ID_REQUEST => Riakpb::RpbGetClientIdResp,
|
60
60
|
SET_CLIENT_ID_REQUEST => nil,
|
61
|
-
GET_SERVER_INFO_REQUEST =>
|
62
|
-
GET_REQUEST =>
|
63
|
-
PUT_REQUEST =>
|
61
|
+
GET_SERVER_INFO_REQUEST => Riakpb::RpbGetServerInfoResp,
|
62
|
+
GET_REQUEST => Riakpb::RpbGetResp,
|
63
|
+
PUT_REQUEST => Riakpb::RpbPutResp,
|
64
64
|
DEL_REQUEST => nil,
|
65
|
-
LIST_BUCKETS_REQUEST =>
|
66
|
-
LIST_KEYS_REQUEST =>
|
67
|
-
GET_BUCKET_REQUEST =>
|
65
|
+
LIST_BUCKETS_REQUEST => Riakpb::RpbListBucketsResp,
|
66
|
+
LIST_KEYS_REQUEST => Riakpb::RpbListKeysResp,
|
67
|
+
GET_BUCKET_REQUEST => Riakpb::RpbGetBucketResp,
|
68
68
|
SET_BUCKET_REQUEST => nil,
|
69
|
-
MAP_REDUCE_REQUEST =>
|
69
|
+
MAP_REDUCE_REQUEST => Riakpb::RpbMapRedResp
|
70
70
|
}
|
71
71
|
end
|
72
72
|
end
|
data/lib/riak.rb
CHANGED
@@ -8,14 +8,14 @@ require 'yaml'
|
|
8
8
|
require 'base64'
|
9
9
|
require 'riak/client_pb'
|
10
10
|
|
11
|
-
module
|
12
|
-
VERSION = '0.
|
11
|
+
module Riakpb
|
12
|
+
VERSION = '0.2.0'
|
13
13
|
|
14
14
|
# Domain objects
|
15
15
|
autoload :I18n, 'riak/i18n'
|
16
16
|
autoload :Client, 'riak/client'
|
17
17
|
autoload :Key, 'riak/key'
|
18
|
-
autoload :
|
18
|
+
autoload :Content, 'riak/content'
|
19
19
|
autoload :Bucket, 'riak/bucket'
|
20
20
|
autoload :MapReduce, 'riak/map_reduce'
|
21
21
|
|
data/load_stocks.rb
CHANGED
data/spec/riak/bucket_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Riakpb::Bucket do
|
4
4
|
describe "when directly initializing" do
|
5
5
|
before :each do
|
6
|
-
@client =
|
6
|
+
@client = Riakpb::Client.new
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should default with the client and name, and empty n_val or allow_mult" do
|
10
|
-
bucket =
|
10
|
+
bucket = Riakpb::Bucket.new(@client, "test")
|
11
11
|
bucket.client.should == @client
|
12
12
|
bucket.name.should == "test"
|
13
13
|
bucket.n_val.should == nil
|
@@ -15,14 +15,14 @@ describe Riak::Bucket do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should correctly accept an n_val" do
|
18
|
-
bucket =
|
18
|
+
bucket = Riakpb::Bucket.new(@client, "test")
|
19
19
|
bucket.n_val = 5
|
20
20
|
bucket.n_val.should be_kind_of(Fixnum)
|
21
21
|
lambda { bucket.n_val="5" }.should raise_error(ArgumentError)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should correctly accept an allow_mult" do
|
25
|
-
bucket =
|
25
|
+
bucket = Riakpb::Bucket.new(@client, "test")
|
26
26
|
bucket.allow_mult = true
|
27
27
|
bucket.allow_mult.should be_kind_of(TrueClass)
|
28
28
|
bucket.allow_mult = false
|
@@ -33,16 +33,16 @@ describe Riak::Bucket do
|
|
33
33
|
|
34
34
|
describe "when initialized from the Client" do
|
35
35
|
before :each do
|
36
|
-
@client =
|
36
|
+
@client = Riakpb::Client.new
|
37
37
|
@client.rpc.stub!(:request).and_return(nil)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should have set the properties" do
|
41
41
|
@client.rpc.stub!(:request).with(
|
42
|
-
|
43
|
-
|
42
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
43
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
44
44
|
).and_return(
|
45
|
-
|
45
|
+
Riakpb::RpbGetBucketResp.new(
|
46
46
|
{ :props => {
|
47
47
|
:allow_mult => false,
|
48
48
|
:n_val => 3
|
@@ -50,7 +50,7 @@ describe Riak::Bucket do
|
|
50
50
|
}
|
51
51
|
))
|
52
52
|
bucket = @client["goog"]
|
53
|
-
bucket.should be_kind_of(
|
53
|
+
bucket.should be_kind_of(Riakpb::Bucket)
|
54
54
|
bucket.client.should == @client
|
55
55
|
bucket.name.should == "goog"
|
56
56
|
bucket.n_val.should == 3
|
@@ -60,12 +60,12 @@ describe Riak::Bucket do
|
|
60
60
|
|
61
61
|
describe "key retrieval" do
|
62
62
|
before :each do
|
63
|
-
@client =
|
63
|
+
@client = Riakpb::Client.new
|
64
64
|
@client.rpc.stub!(:request).with(
|
65
|
-
|
66
|
-
|
65
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
66
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
67
67
|
).and_return(
|
68
|
-
|
68
|
+
Riakpb::RpbGetBucketResp.new(
|
69
69
|
{ :props => {
|
70
70
|
:allow_mult => false,
|
71
71
|
:n_val => 3
|
@@ -77,10 +77,10 @@ describe Riak::Bucket do
|
|
77
77
|
|
78
78
|
it "should list the keys within the bucket" do
|
79
79
|
@client.rpc.stub!(:request).with(
|
80
|
-
|
81
|
-
|
80
|
+
Riakpb::Util::MessageCode::LIST_KEYS_REQUEST,
|
81
|
+
Riakpb::RpbListKeysReq.new(:bucket => "goog")
|
82
82
|
).and_return(
|
83
|
-
|
83
|
+
Riakpb::RpbListKeysResp.new(
|
84
84
|
{ :keys => ["2010-04-12", "2008-01-10", "2006-06-06"],
|
85
85
|
:done => true
|
86
86
|
}
|
@@ -90,16 +90,16 @@ describe Riak::Bucket do
|
|
90
90
|
|
91
91
|
it "should return a key, when requested" do
|
92
92
|
@client.rpc.stub!(:request).with(
|
93
|
-
|
94
|
-
|
93
|
+
Riakpb::Util::MessageCode::GET_REQUEST,
|
94
|
+
Riakpb::RpbGetReq.new(:bucket => "goog", :key => "2010-04-12", :r => nil)
|
95
95
|
).and_return(
|
96
|
-
|
96
|
+
Riakpb::RpbGetResp.new(
|
97
97
|
{ :content => [],
|
98
98
|
:vclock => ""
|
99
99
|
}
|
100
100
|
))
|
101
|
-
@bucket["2010-04-12"].should be_kind_of(
|
101
|
+
@bucket["2010-04-12"].should be_kind_of(Riakpb::Key)
|
102
102
|
end
|
103
103
|
end # describe "key retrieval"
|
104
104
|
|
105
|
-
end #
|
105
|
+
end # Riakpb::Client
|
data/spec/riak/client_spec.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Riakpb::Client do
|
4
4
|
describe "when initializing" do
|
5
5
|
it "should default to the local interface on port 8087" do
|
6
|
-
client =
|
6
|
+
client = Riakpb::Client.new
|
7
7
|
client.host.should == "127.0.0.1"
|
8
8
|
client.port.should == 8087
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should accept a host" do
|
12
|
-
client =
|
12
|
+
client = Riakpb::Client.new :host => "riak.basho.com"
|
13
13
|
client.host.should == "riak.basho.com"
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should accept a port" do
|
17
|
-
client =
|
17
|
+
client = Riakpb::Client.new :port => 9000
|
18
18
|
client.port.should == 9000
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "reconfiguring" do
|
23
23
|
before :each do
|
24
|
-
@client =
|
24
|
+
@client = Riakpb::Client.new
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "setting the host" do
|
@@ -70,18 +70,18 @@ describe Riak::Client do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should reject an integer equal to the maximum client id" do
|
73
|
-
lambda { @client.client_id =
|
73
|
+
lambda { @client.client_id = Riakpb::Client::MAX_CLIENT_ID }.should raise_error(ArgumentError)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should reject an integer larger than the maximum client id" do
|
77
|
-
lambda { @client.client_id =
|
77
|
+
lambda { @client.client_id = Riakpb::Client::MAX_CLIENT_ID + 1 }.should raise_error(ArgumentError)
|
78
78
|
end
|
79
79
|
end # describe "setting the client id"
|
80
80
|
end # describe "reconfiguring"
|
81
81
|
|
82
82
|
describe "sending and receiving protocol buffers" do
|
83
83
|
before :each do
|
84
|
-
@client =
|
84
|
+
@client = Riakpb::Client.new
|
85
85
|
@client.rpc.stub!(:status).and_return(true)
|
86
86
|
@client.rpc.stub!(:request).and_return(nil)
|
87
87
|
end
|
@@ -89,7 +89,7 @@ describe Riak::Client do
|
|
89
89
|
describe "basic communication with riak node" do
|
90
90
|
it "should send a ping request and return true" do
|
91
91
|
@client.rpc.stub!(:request).with(
|
92
|
-
|
92
|
+
Riakpb::Util::MessageCode::PING_REQUEST
|
93
93
|
).and_return('')
|
94
94
|
|
95
95
|
@client.ping?.should == true
|
@@ -98,8 +98,8 @@ describe Riak::Client do
|
|
98
98
|
it "should request the connected riak node's server info and return a Hash" do
|
99
99
|
# test length or content? Need to look at what are considered acceptable values
|
100
100
|
@client.rpc.stub!(:request).with(
|
101
|
-
|
102
|
-
).and_return(
|
101
|
+
Riakpb::Util::MessageCode::GET_SERVER_INFO_REQUEST
|
102
|
+
).and_return(Riakpb::RpbGetServerInfoResp.new(
|
103
103
|
{ :node => "riak@127.0.0.1",
|
104
104
|
:server_version => "0.10.1"
|
105
105
|
}
|
@@ -115,21 +115,21 @@ describe Riak::Client do
|
|
115
115
|
describe "bucket retrieval (get)" do
|
116
116
|
it "should send a request to list available bucket names and return a Protobuf::Field::FieldArray" do
|
117
117
|
@client.rpc.stub!(:request).with(
|
118
|
-
|
118
|
+
Riakpb::Util::MessageCode::LIST_BUCKETS_REQUEST
|
119
119
|
).and_return(
|
120
|
-
|
120
|
+
Riakpb::RpbListBucketsResp.new(
|
121
121
|
{ :buckets => ["goog"] }
|
122
122
|
))
|
123
123
|
|
124
124
|
@client.buckets.should be_kind_of(Protobuf::Field::FieldArray)
|
125
125
|
end
|
126
126
|
|
127
|
-
it "should send a request with the bucket name and return a
|
127
|
+
it "should send a request with the bucket name and return a Riakpb::Bucket" do
|
128
128
|
@client.rpc.stub!(:request).with(
|
129
|
-
|
130
|
-
|
129
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
130
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
131
131
|
).and_return(
|
132
|
-
|
132
|
+
Riakpb::RpbGetBucketResp.new(
|
133
133
|
{ :props => {
|
134
134
|
:allow_mult => false,
|
135
135
|
:n_val => 3
|
@@ -137,15 +137,15 @@ describe Riak::Client do
|
|
137
137
|
}
|
138
138
|
))
|
139
139
|
|
140
|
-
@client.bucket("goog").should be_kind_of(
|
140
|
+
@client.bucket("goog").should be_kind_of(Riakpb::Bucket)
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should send a request to list keys within a bucket and return a Protobuf::Field::FieldArray" do
|
144
144
|
@client.rpc.stub!(:request).with(
|
145
|
-
|
146
|
-
|
145
|
+
Riakpb::Util::MessageCode::LIST_KEYS_REQUEST,
|
146
|
+
Riakpb::RpbListKeysReq.new(:bucket => "goog")
|
147
147
|
).and_return(
|
148
|
-
|
148
|
+
Riakpb::RpbListKeysResp.new(
|
149
149
|
{ :keys => ["2010-04-12", "2008-01-10", "2006-06-06"],
|
150
150
|
:done => true
|
151
151
|
}
|
@@ -161,21 +161,21 @@ describe Riak::Client do
|
|
161
161
|
describe "key operations: retrieval (get), send (put) and delete (del)" do
|
162
162
|
before :each do
|
163
163
|
@client.rpc.stub!(:request).with(
|
164
|
-
|
165
|
-
|
164
|
+
Riakpb::Util::MessageCode::GET_REQUEST,
|
165
|
+
Riakpb::RpbGetReq.new(:bucket => "goog", :key => "2010-04-12", :r => nil)
|
166
166
|
).and_return(
|
167
|
-
|
167
|
+
Riakpb::RpbGetResp.new(
|
168
168
|
{ :content => [],
|
169
169
|
:vclock => ""
|
170
170
|
}
|
171
171
|
))
|
172
172
|
end
|
173
173
|
|
174
|
-
it "should send a request for a bucket/key pair and return a
|
175
|
-
@client.get_request("goog", "2010-04-12").should be_kind_of(
|
174
|
+
it "should send a request for a bucket/key pair and return a Riakpb::RpbGetResp" do
|
175
|
+
@client.get_request("goog", "2010-04-12").should be_kind_of(Riakpb::RpbGetResp)
|
176
176
|
end
|
177
177
|
|
178
|
-
it "should have a vclock attribute within
|
178
|
+
it "should have a vclock attribute within Riakpb::RpbGetResp of that is a String" do
|
179
179
|
@client.get_request("goog", "2010-04-12").vclock.should be_kind_of(String)
|
180
180
|
end
|
181
181
|
end # describe "key operations and retrieval"
|
@@ -183,10 +183,10 @@ describe Riak::Client do
|
|
183
183
|
describe "key operations and retrieval" do
|
184
184
|
before :each do
|
185
185
|
@client.rpc.stub!(:request).with(
|
186
|
-
|
187
|
-
|
186
|
+
Riakpb::Util::MessageCode::GET_REQUEST,
|
187
|
+
Riakpb::RpbGetReq.new(:bucket => "goog", :key => "2010-04-12", :r => nil)
|
188
188
|
).and_return(
|
189
|
-
|
189
|
+
Riakpb::RpbGetResp.new(
|
190
190
|
{ :content => [],
|
191
191
|
:vclock => ""
|
192
192
|
}
|
@@ -196,4 +196,4 @@ describe Riak::Client do
|
|
196
196
|
|
197
197
|
end # describe "key operations and retrieval"
|
198
198
|
end # describe "basic communication with riak node"
|
199
|
-
end #
|
199
|
+
end # Riakpb::Client
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Riakpb::Content do
|
4
4
|
describe "when directly initializing" do
|
5
5
|
before :each do
|
6
|
-
@client =
|
6
|
+
@client = Riakpb::Client.new
|
7
7
|
@client.rpc.stub!(:request).with(
|
8
|
-
|
9
|
-
|
8
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
9
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
10
10
|
).and_return(
|
11
|
-
|
11
|
+
Riakpb::RpbGetBucketResp.new(
|
12
12
|
{ :props => {
|
13
13
|
:allow_mult => false,
|
14
14
|
:n_val => 3
|
@@ -16,11 +16,11 @@ describe Riak::RiakContent do
|
|
16
16
|
}
|
17
17
|
))
|
18
18
|
@bucket = @client["goog"]
|
19
|
-
@key =
|
19
|
+
@key = Riakpb::Key.new(@bucket, "test")
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should default with nil attributes and links/usermeta as instances of Set/Hash" do
|
23
|
-
rcontent =
|
23
|
+
rcontent = Riakpb::Content.new(@key)
|
24
24
|
rcontent.key.should == @key
|
25
25
|
rcontent.value.should == nil
|
26
26
|
rcontent.content_type.should == nil
|
@@ -28,30 +28,30 @@ describe Riak::RiakContent do
|
|
28
28
|
rcontent.content_encoding.should == nil
|
29
29
|
rcontent.vtag.should == nil
|
30
30
|
rcontent.links.should be_kind_of(Hash)
|
31
|
-
rcontent.last_mod.should
|
31
|
+
rcontent.last_mod.should be_kind_of(Time)
|
32
32
|
rcontent.last_mod_usecs.should == nil
|
33
33
|
rcontent.usermeta.should be_kind_of(Hash)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should allow you to set the Key, after initialization" do
|
37
|
-
rcontent =
|
37
|
+
rcontent = Riakpb::Content.new(@key)
|
38
38
|
rcontent.key = @key
|
39
39
|
rcontent.key.should == @key
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should accept a Key as an argument to new, tying it back to an owner" do
|
43
|
-
rcontent =
|
43
|
+
rcontent = Riakpb::Content.new(@key)
|
44
44
|
rcontent.key.should == @key
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should serialize into a corresponding Protocol Buffer (RpbContent)" do
|
48
|
-
rcontent =
|
49
|
-
rcontent.to_pb.should be_kind_of(
|
48
|
+
rcontent = Riakpb::Content.new(@key, :value => "Test")
|
49
|
+
rcontent.to_pb.should be_kind_of(Riakpb::RpbContent)
|
50
50
|
end
|
51
51
|
|
52
|
-
it "should load a
|
53
|
-
rcontent =
|
54
|
-
rpb_content =
|
52
|
+
it "should load a Riakpb::RpbContent instance, returning a matching self, Content" do
|
53
|
+
rcontent = Riakpb::Content.new(@key)
|
54
|
+
rpb_content = Riakpb::RpbContent.new
|
55
55
|
rpb_content.value = "{\"Date\":\"2010-04-12\",\"Open\":567.35,\"High\":574.00,\"Low\":566.22,\"Close\":572.73,\"Volume\":2352400,\"Adj. Close\":572.73}"
|
56
56
|
rpb_content.content_type = "application/json"
|
57
57
|
rpb_content.vtag = "4DNB6Vt0zLl5VJ6P2xx9dc"
|
@@ -66,10 +66,9 @@ describe Riak::RiakContent do
|
|
66
66
|
rcontent.content_encoding.should == nil
|
67
67
|
rcontent.vtag.should == "4DNB6Vt0zLl5VJ6P2xx9dc"
|
68
68
|
rcontent.links.should be_kind_of(Hash)
|
69
|
-
rcontent.last_mod.should == 1274645855
|
70
|
-
rcontent.last_mod_usecs.should == 968694
|
69
|
+
rcontent.last_mod.should == Time.at(1274645855.968694)
|
71
70
|
rcontent.usermeta.should be_kind_of(Hash)
|
72
71
|
end
|
73
72
|
|
74
73
|
end # describe "when directly initializing"
|
75
|
-
end #
|
74
|
+
end # Riakpb::Content
|
data/spec/riak/key_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Riakpb::Key do
|
4
4
|
describe "when directly initializing" do
|
5
5
|
before :each do
|
6
|
-
@client =
|
6
|
+
@client = Riakpb::Client.new
|
7
7
|
@client.rpc.stub!(:request).with(
|
8
|
-
|
9
|
-
|
8
|
+
Riakpb::Util::MessageCode::GET_BUCKET_REQUEST,
|
9
|
+
Riakpb::RpbGetBucketReq.new(:bucket => "goog")
|
10
10
|
).and_return(
|
11
|
-
|
11
|
+
Riakpb::RpbGetBucketResp.new(
|
12
12
|
{ :props => {
|
13
13
|
:allow_mult => false,
|
14
14
|
:n_val => 3
|
@@ -19,36 +19,36 @@ describe Riak::Key do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should default with the bucket and name, and an empty vclock" do
|
22
|
-
key =
|
22
|
+
key = Riakpb::Key.new(@bucket, "test")
|
23
23
|
key.bucket.should == @bucket
|
24
24
|
key.name.should == "test"
|
25
25
|
key.vclock.should == nil
|
26
|
-
key.content.should be_kind_of(
|
26
|
+
key.content.should be_kind_of(Riakpb::Content)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should serialize into a Key Protocol Buffer (RpbPutReq)" do
|
30
30
|
@client.rpc.stub!(:request).with(
|
31
|
-
|
32
|
-
|
31
|
+
Riakpb::Util::MessageCode::GET_REQUEST,
|
32
|
+
Riakpb::RpbGetReq.new(:bucket => "goog", :key => "2010-04-12", :r => nil)
|
33
33
|
).and_return(
|
34
|
-
|
35
|
-
{ :content => [
|
34
|
+
Riakpb::RpbGetResp.new(
|
35
|
+
{ :content => [Riakpb::RpbContent.new(:value => "Test")],
|
36
36
|
:vclock => "k\xCEa```\xCC`\xCA\x05R,\xACL\xF7^e0%2\xE6\xB12\xC4s\xE6\x1D\xE5\xCB\x02\x00"
|
37
37
|
}
|
38
38
|
))
|
39
|
-
key = @bucket["2010-04-12"] #
|
39
|
+
key = @bucket["2010-04-12"] # Riakpb::Key.new(@bucket, "test")
|
40
40
|
pb_put = key.to_pb_put
|
41
|
-
pb_put.should be_kind_of(
|
41
|
+
pb_put.should be_kind_of(Riakpb::RpbPutReq)
|
42
42
|
pb_put.vclock.should == "k\xCEa```\xCC`\xCA\x05R,\xACL\xF7^e0%2\xE6\xB12\xC4s\xE6\x1D\xE5\xCB\x02\x00"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should serialize into a Link Protocol Buffer (RpbLink)" do
|
46
|
-
key =
|
46
|
+
key = Riakpb::Key.new(@bucket, "test")
|
47
47
|
pb_link = key.to_pb_link
|
48
|
-
pb_link.should be_kind_of(
|
48
|
+
pb_link.should be_kind_of(Riakpb::RpbLink)
|
49
49
|
pb_link.bucket.should == "goog"
|
50
50
|
pb_link.key.should == "test"
|
51
51
|
end
|
52
52
|
end # describe "when directly initializing"
|
53
|
-
end #
|
53
|
+
end # Riakpb::Key
|
54
54
|
|