okuyama 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/okuyama/protocol/version1.rb +11 -1
- data/okuyama.gemspec +2 -5
- data/spec/okuyama/client_spec.rb +152 -20
- metadata +4 -7
- data/spec/okuyama/client/decr_value_spec.rb +0 -99
- data/spec/okuyama/client/incr_value_spec.rb +0 -99
- data/spec/okuyama/client/search_spec.rb +0 -135
data/History.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -13,9 +13,19 @@ module Okuyama
|
|
13
13
|
return '1.0.0'
|
14
14
|
end
|
15
15
|
|
16
|
+
def print_encode(socket, text)
|
17
|
+
if @base64_encode_flag then
|
18
|
+
Base64.encode64(text).split.each do |line|
|
19
|
+
socket.print line
|
20
|
+
end
|
21
|
+
else
|
22
|
+
socket.print text
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
def encode(text)
|
17
27
|
return text if ! @base64_encode_flag
|
18
|
-
return Base64.encode64(text).
|
28
|
+
return Base64.encode64(text).split.join
|
19
29
|
end
|
20
30
|
|
21
31
|
def decode(text)
|
data/okuyama.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "okuyama"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kenji Hara"]
|
12
|
-
s.date = "2012-03-
|
12
|
+
s.date = "2012-03-28"
|
13
13
|
s.description = "okuyama client for Ruby"
|
14
14
|
s.email = "haracane@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,9 +32,6 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/okuyama/protocol/abstract_protocol.rb",
|
33
33
|
"lib/okuyama/protocol/version1.rb",
|
34
34
|
"okuyama.gemspec",
|
35
|
-
"spec/okuyama/client/decr_value_spec.rb",
|
36
|
-
"spec/okuyama/client/incr_value_spec.rb",
|
37
|
-
"spec/okuyama/client/search_spec.rb",
|
38
35
|
"spec/okuyama/client_spec.rb",
|
39
36
|
"spec/okuyama/protocol/version1_spec.rb",
|
40
37
|
"spec/okuyama_spec.rb",
|
data/spec/okuyama/client_spec.rb
CHANGED
@@ -6,16 +6,18 @@ describe Okuyama::Client do
|
|
6
6
|
describe "when base64_encode_flag = #{base64_encode_flag}" do
|
7
7
|
|
8
8
|
before :each do
|
9
|
+
@testnumval_int = 10
|
10
|
+
@testnumval = @testnumval_int.to_s
|
11
|
+
|
9
12
|
@testnumkey = 'testnumkey'
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@testval1 = 'testval1'
|
13
|
+
@testkey1 = 'testkey1_0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz'
|
14
|
+
@testval1 = 'testval1_0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz'
|
13
15
|
@testkey2 = 'testkey2'
|
14
16
|
@testval2 = 'testval2'
|
15
17
|
@testnewkey = 'testnewkey'
|
16
18
|
@testnewval = 'testnewval'
|
17
19
|
@testnewval1 = 'testnewval1'
|
18
|
-
@testtag = '
|
20
|
+
@testtag = 'testtag_0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz'
|
19
21
|
@testnewtag = 'testnewtag'
|
20
22
|
@testgroup = 'testgroup'
|
21
23
|
@testnewgroup = 'testnewgroup'
|
@@ -24,22 +26,23 @@ describe Okuyama::Client do
|
|
24
26
|
@testnewquery = 'testnewval'
|
25
27
|
|
26
28
|
if base64_encode_flag == false then
|
27
|
-
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
29
|
+
protocol = Okuyama::Protocol::Version1.new
|
30
|
+
@testnumkey = protocol.encode(@testnumkey)
|
31
|
+
@testnumval = protocol.encode(@testnumval)
|
32
|
+
@testkey1 = protocol.encode(@testkey1)
|
33
|
+
@testval1 = protocol.encode(@testval1)
|
34
|
+
@testkey2 = protocol.encode(@testkey2)
|
35
|
+
@testval2 = protocol.encode(@testval2)
|
36
|
+
@testnewkey = protocol.encode(@testnewkey)
|
37
|
+
@testnewval = protocol.encode(@testnewval)
|
38
|
+
@testnewval1 = protocol.encode(@testnewval1)
|
39
|
+
@testtag = protocol.encode(@testtag)
|
40
|
+
@testnewtag = protocol.encode(@testnewtag)
|
41
|
+
@testgroup = protocol.encode(@testgroup)
|
42
|
+
@testnewgroup = protocol.encode(@testnewgroup)
|
43
|
+
@testquery1 = protocol.encode(@testquery1)
|
44
|
+
@testquery2 = protocol.encode(@testquery2)
|
45
|
+
@testnewquery = protocol.encode(@testnewquery)
|
43
46
|
end
|
44
47
|
|
45
48
|
@client = Okuyama::Client.new(:host=>'localhost', :port=>8888, :base64_encode_flag=>base64_encode_flag)
|
@@ -499,7 +502,136 @@ describe Okuyama::Client do
|
|
499
502
|
end
|
500
503
|
end
|
501
504
|
|
505
|
+
describe "set_value_and_create_index(key, val, :tags=>tags, :group=>group, :min_n=>min_n, :max_n=>max_n)" do
|
506
|
+
describe "when key exists," do
|
507
|
+
it "should success" do
|
508
|
+
result = @client.set_value_and_create_index(@testkey1, @testval1, :tags=>[@testtag], :group=>@testgroup, :min_n=>1, :max_n=>3)
|
509
|
+
result.should be_true
|
510
|
+
end
|
511
|
+
end
|
512
|
+
describe "when key does not exist," do
|
513
|
+
it "should success" do
|
514
|
+
result = @client.set_value_and_create_index(@testnewkey, @testnewval, :tags=>[@testnewtag], :group=>@testnewgroup, :min_n=>1, :max_n=>3)
|
515
|
+
result.should be_true
|
516
|
+
end
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
describe "search_value(query)" do
|
521
|
+
describe "when key exists," do
|
522
|
+
it "should return keys" do
|
523
|
+
result = @client.search_value(@testquery1)
|
524
|
+
result.sort!
|
525
|
+
result.should == [@testkey1]
|
526
|
+
end
|
527
|
+
end
|
528
|
+
describe "when key does not exist," do
|
529
|
+
it "should return []" do
|
530
|
+
result = @client.search_value(@testnewquery)
|
531
|
+
result.should == []
|
532
|
+
end
|
533
|
+
end
|
534
|
+
end
|
535
|
+
|
536
|
+
describe "search_value(query, :condition=>:and, :group=>group, :nsize=>nsize)" do
|
537
|
+
if false then
|
538
|
+
describe "when key exists," do
|
539
|
+
it "should return keys" do
|
540
|
+
result = @client.search_value([@testquery1, @testquery2], :condition=>:and, :group=>@testgroup, :nsize=>3)
|
541
|
+
result.sort!
|
542
|
+
result.should == ['testkey1']
|
543
|
+
end
|
544
|
+
end
|
545
|
+
end
|
546
|
+
describe "when key does not exist," do
|
547
|
+
it "should return []" do
|
548
|
+
result = @client.search_value([@testquery1, @testnewquery], :condition=>:and, :group=>@testgroup, :nsize=>3)
|
549
|
+
result.should == []
|
550
|
+
end
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
describe "search_value(query, :condition=>:or, :group=>group, :nsize=>nsize)" do
|
555
|
+
if false then
|
556
|
+
describe "when key exists," do
|
557
|
+
it "should return keys" do
|
558
|
+
result = @client.search_value([@testquery1, @testquery2], :condition=>:or, :group=>@testgroup, :nsize=>3)
|
559
|
+
result.sort!
|
560
|
+
result.should == ['testkey1']
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|
564
|
+
describe "when key does not exist," do
|
565
|
+
it "should return []" do
|
566
|
+
result = @client.search_value([@testnewquery, @testnewquery], :condition=>:or, :group=>@testgroup, :nsize=>3)
|
567
|
+
result.should == []
|
568
|
+
end
|
569
|
+
end
|
570
|
+
end
|
502
571
|
|
572
|
+
describe "incr_value(key, val)" do
|
573
|
+
describe "when key exists," do
|
574
|
+
describe "when value is a number" do
|
575
|
+
it "should return incremented value(integer)" do
|
576
|
+
Okuyama.logger.debug("send: #{@client.protocol.message_of_incr_value(@testnumkey, '1').inspect}")
|
577
|
+
result = @client.incr_value(@testnumkey, 1)
|
578
|
+
result.should == (@testnumval_int + 1)
|
579
|
+
end
|
580
|
+
it "should return incremented value(text)" do
|
581
|
+
@client.to_i_flag = false
|
582
|
+
result = @client.incr_value(@testnumkey, 1)
|
583
|
+
expected = (@testnumval_int + 1).to_s
|
584
|
+
expected = Base64.encode64(expected).chomp if base64_encode_flag == false
|
585
|
+
result.should == expected
|
586
|
+
end
|
587
|
+
end
|
588
|
+
describe "when value is not a number" do
|
589
|
+
it "should return 1(integer)" do
|
590
|
+
result = @client.incr_value(@testkey1, 1)
|
591
|
+
result.should == 1
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|
595
|
+
describe "when key does not exist," do
|
596
|
+
it "should fail" do
|
597
|
+
Okuyama.logger.debug("send: #{@client.protocol.message_of_incr_value(@testnewkey, '1').inspect}")
|
598
|
+
# result = @client.incr_value(@testnewkey, 1)
|
599
|
+
# result.should be_nil
|
600
|
+
end
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
describe "decr_value(key)" do
|
605
|
+
describe "when key exists," do
|
606
|
+
describe "when value is a number" do
|
607
|
+
it "should return decremented value(integer)" do
|
608
|
+
result = @client.decr_value(@testnumkey, 1)
|
609
|
+
result.should == (@testnumval_int - 1)
|
610
|
+
end
|
611
|
+
it "should return decremented value(text)" do
|
612
|
+
@client.to_i_flag = false
|
613
|
+
val = @client.get_value(@testnumkey)
|
614
|
+
result = @client.decr_value(@testnumkey, 1)
|
615
|
+
expected = (@testnumval_int - 1).to_s
|
616
|
+
expected = Base64.encode64(expected).chomp if base64_encode_flag == false
|
617
|
+
result.should == expected
|
618
|
+
end
|
619
|
+
end
|
620
|
+
describe "when value is not a number" do
|
621
|
+
it "should return 1(integer)" do
|
622
|
+
result = @client.decr_value(@testkey1, 1)
|
623
|
+
result.should == 0
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
627
|
+
describe "when key does not exist," do
|
628
|
+
it "should fail" do
|
629
|
+
# result = @client.decr_value(@testnewkey, 1)
|
630
|
+
# result.should be_nil
|
631
|
+
end
|
632
|
+
end
|
633
|
+
end
|
634
|
+
|
503
635
|
end
|
504
636
|
end
|
505
637
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okuyama
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kenji Hara
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :development
|
@@ -119,9 +119,6 @@ files:
|
|
119
119
|
- lib/okuyama/protocol/abstract_protocol.rb
|
120
120
|
- lib/okuyama/protocol/version1.rb
|
121
121
|
- okuyama.gemspec
|
122
|
-
- spec/okuyama/client/decr_value_spec.rb
|
123
|
-
- spec/okuyama/client/incr_value_spec.rb
|
124
|
-
- spec/okuyama/client/search_spec.rb
|
125
122
|
- spec/okuyama/client_spec.rb
|
126
123
|
- spec/okuyama/protocol/version1_spec.rb
|
127
124
|
- spec/okuyama_spec.rb
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Okuyama::Client do
|
4
|
-
|
5
|
-
[true, false].each do |base64_encode_flag|
|
6
|
-
describe "when base64_encode_flag = #{base64_encode_flag}" do
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
@testnumval_int = 10
|
10
|
-
|
11
|
-
@testnumkey = 'testnumkey'
|
12
|
-
@testnumval = @testnumval_int.to_s
|
13
|
-
@testkey1 = 'testkey1'
|
14
|
-
@testval1 = 'testval1'
|
15
|
-
@testkey2 = 'testkey2'
|
16
|
-
@testval2 = 'testval2'
|
17
|
-
@testnewkey = 'testnewkey'
|
18
|
-
@testnewval = 'testnewval'
|
19
|
-
@testnewval1 = 'testnewval1'
|
20
|
-
@testtag = 'testtag'
|
21
|
-
@testnewtag = 'testnewtag'
|
22
|
-
@testgroup = 'testgroup'
|
23
|
-
@testnewgroup = 'testnewgroup'
|
24
|
-
@testquery1 = 'testval'
|
25
|
-
@testquery2 = 'val1'
|
26
|
-
@testnewquery = 'testnewval'
|
27
|
-
|
28
|
-
if base64_encode_flag == false then
|
29
|
-
@testnumkey = Base64.encode64(@testnumkey).chomp
|
30
|
-
@testnumval = Base64.encode64(@testnumval).chomp
|
31
|
-
@testkey1 = Base64.encode64(@testkey1).chomp
|
32
|
-
@testval1 = Base64.encode64(@testval1).chomp
|
33
|
-
@testkey2 = Base64.encode64(@testkey2).chomp
|
34
|
-
@testval2 = Base64.encode64(@testval2).chomp
|
35
|
-
@testnewkey = Base64.encode64(@testnewkey).chomp
|
36
|
-
@testnewval = Base64.encode64(@testnewval).chomp
|
37
|
-
@testnewval1 = Base64.encode64(@testnewval1).chomp
|
38
|
-
@testtag = Base64.encode64(@testtag).chomp
|
39
|
-
@testnewtag = Base64.encode64(@testnewtag).chomp
|
40
|
-
@testgroup = Base64.encode64(@testgroup).chomp
|
41
|
-
@testnewgroup = Base64.encode64(@testnewgroup).chomp
|
42
|
-
@testquery1 = Base64.encode64(@testquery1).chomp
|
43
|
-
@testquery2 = Base64.encode64(@testquery2).chomp
|
44
|
-
@testnewquery = Base64.encode64(@testnewquery).chomp
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
@client = Okuyama::Client.new(:host=>'localhost', :port=>8888, :base64_encode_flag=>base64_encode_flag)
|
49
|
-
@client.debug = true
|
50
|
-
@client.remove_value(@testnumkey)
|
51
|
-
@client.remove_value(@testkey1)
|
52
|
-
@client.remove_value(@testkey2)
|
53
|
-
@client.remove_value(@testnewkey)
|
54
|
-
@client.remove_tag_from_key(@testnewtag, @testkey1)
|
55
|
-
@client.set_value(@testnumkey, @testnumval)
|
56
|
-
@client.set_value_and_create_index(@testkey1, @testval1, :tags=>[@testtag], :group=>@testgroup, :min_n=>1, :max_n=>3)
|
57
|
-
@client.set_value(@testkey2, @testval2, @testtag)
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
after :each do
|
62
|
-
@client.close
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "decr_value(key)" do
|
66
|
-
describe "when key exists," do
|
67
|
-
describe "when value is a number" do
|
68
|
-
it "should return decremented value(integer)" do
|
69
|
-
result = @client.decr_value(@testnumkey, 1)
|
70
|
-
result.should == (@testnumval_int - 1)
|
71
|
-
end
|
72
|
-
it "should return decremented value(text)" do
|
73
|
-
@client.to_i_flag = false
|
74
|
-
val = @client.get_value(@testnumkey)
|
75
|
-
result = @client.decr_value(@testnumkey, 1)
|
76
|
-
expected = (@testnumval_int - 1).to_s
|
77
|
-
expected = Base64.encode64(expected).chomp if base64_encode_flag == false
|
78
|
-
result.should == expected
|
79
|
-
end
|
80
|
-
end
|
81
|
-
describe "when value is not a number" do
|
82
|
-
it "should return 1(integer)" do
|
83
|
-
result = @client.decr_value(@testkey1, 1)
|
84
|
-
result.should == 0
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
describe "when key does not exist," do
|
89
|
-
it "should fail" do
|
90
|
-
# result = @client.decr_value(@testnewkey, 1)
|
91
|
-
# result.should be_nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Okuyama::Client do
|
4
|
-
|
5
|
-
[true,false].each do |base64_encode_flag|
|
6
|
-
describe "when base64_encode_flag = #{base64_encode_flag}" do
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
@testnumval_int = 10
|
10
|
-
|
11
|
-
@testnumkey = 'testnumkey'
|
12
|
-
@testnumval = @testnumval_int.to_s
|
13
|
-
@testkey1 = 'testkey1'
|
14
|
-
@testval1 = 'testval1'
|
15
|
-
@testkey2 = 'testkey2'
|
16
|
-
@testval2 = 'testval2'
|
17
|
-
@testnewkey = 'testnewkey'
|
18
|
-
@testnewval = 'testnewval'
|
19
|
-
@testnewval1 = 'testnewval1'
|
20
|
-
@testtag = 'testtag'
|
21
|
-
@testnewtag = 'testnewtag'
|
22
|
-
@testgroup = 'testgroup'
|
23
|
-
@testnewgroup = 'testnewgroup'
|
24
|
-
@testquery1 = 'testval'
|
25
|
-
@testquery2 = 'val1'
|
26
|
-
@testnewquery = 'testnewval'
|
27
|
-
|
28
|
-
if base64_encode_flag == false then
|
29
|
-
@testnumkey = Base64.encode64(@testnumkey).chomp
|
30
|
-
@testnumval = Base64.encode64(@testnumval).chomp
|
31
|
-
@testkey1 = Base64.encode64(@testkey1).chomp
|
32
|
-
@testval1 = Base64.encode64(@testval1).chomp
|
33
|
-
@testkey2 = Base64.encode64(@testkey2).chomp
|
34
|
-
@testval2 = Base64.encode64(@testval2).chomp
|
35
|
-
@testnewkey = Base64.encode64(@testnewkey).chomp
|
36
|
-
@testnewval = Base64.encode64(@testnewval).chomp
|
37
|
-
@testnewval1 = Base64.encode64(@testnewval1).chomp
|
38
|
-
@testtag = Base64.encode64(@testtag).chomp
|
39
|
-
@testnewtag = Base64.encode64(@testnewtag).chomp
|
40
|
-
@testgroup = Base64.encode64(@testgroup).chomp
|
41
|
-
@testnewgroup = Base64.encode64(@testnewgroup).chomp
|
42
|
-
@testquery1 = Base64.encode64(@testquery1).chomp
|
43
|
-
@testquery2 = Base64.encode64(@testquery2).chomp
|
44
|
-
@testnewquery = Base64.encode64(@testnewquery).chomp
|
45
|
-
end
|
46
|
-
|
47
|
-
@client = Okuyama::Client.new(:host=>'localhost', :port=>8888, :base64_encode_flag=>base64_encode_flag)
|
48
|
-
@client.debug = true
|
49
|
-
@client.remove_value(@testnumkey)
|
50
|
-
@client.remove_value(@testkey1)
|
51
|
-
@client.remove_value(@testkey2)
|
52
|
-
@client.remove_value(@testnewkey)
|
53
|
-
@client.remove_tag_from_key(@testnewtag, @testkey1)
|
54
|
-
@client.set_value(@testnumkey, @testnumval)
|
55
|
-
@client.set_value_and_create_index(@testkey1, @testval1, :tags=>[@testtag], :group=>@testgroup, :min_n=>1, :max_n=>3)
|
56
|
-
@client.set_value(@testkey2, @testval2, @testtag)
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
after :each do
|
61
|
-
@client.close
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "incr_value(key, val)" do
|
65
|
-
describe "when key exists," do
|
66
|
-
describe "when value is a number" do
|
67
|
-
it "should return incremented value(integer)" do
|
68
|
-
Okuyama.logger.debug("send: #{@client.protocol.message_of_incr_value(@testnumkey, '1').inspect}")
|
69
|
-
result = @client.incr_value(@testnumkey, 1)
|
70
|
-
result.should == (@testnumval_int + 1)
|
71
|
-
end
|
72
|
-
it "should return incremented value(text)" do
|
73
|
-
@client.to_i_flag = false
|
74
|
-
result = @client.incr_value(@testnumkey, 1)
|
75
|
-
expected = (@testnumval_int + 1).to_s
|
76
|
-
expected = Base64.encode64(expected).chomp if base64_encode_flag == false
|
77
|
-
result.should == expected
|
78
|
-
end
|
79
|
-
end
|
80
|
-
describe "when value is not a number" do
|
81
|
-
it "should return 1(integer)" do
|
82
|
-
result = @client.incr_value(@testkey1, 1)
|
83
|
-
result.should == 1
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
describe "when key does not exist," do
|
88
|
-
it "should fail" do
|
89
|
-
Okuyama.logger.debug("send: #{@client.protocol.message_of_incr_value(@testnewkey, '1').inspect}")
|
90
|
-
# result = @client.incr_value(@testnewkey, 1)
|
91
|
-
# result.should be_nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Okuyama::Client do
|
4
|
-
|
5
|
-
[true, false].each do |base64_encode_flag|
|
6
|
-
describe "when base64_encode_flag = #{base64_encode_flag}" do
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
@testnumval_int = 10
|
10
|
-
|
11
|
-
@testnumkey = 'testnumkey'
|
12
|
-
@testnumval = @testnumval_int.to_s
|
13
|
-
@testkey1 = 'testkey1'
|
14
|
-
@testval1 = 'testval1'
|
15
|
-
@testkey2 = 'testkey2'
|
16
|
-
@testval2 = 'testval2'
|
17
|
-
@testnewkey = 'testnewkey'
|
18
|
-
@testnewval = 'testnewval'
|
19
|
-
@testnewval1 = 'testnewval1'
|
20
|
-
@testtag = 'testtag'
|
21
|
-
@testnewtag = 'testnewtag'
|
22
|
-
@testgroup = 'testgroup'
|
23
|
-
@testnewgroup = 'testnewgroup'
|
24
|
-
@testquery1 = 'testval'
|
25
|
-
@testquery2 = 'val1'
|
26
|
-
@testnewquery = 'testnewval'
|
27
|
-
|
28
|
-
if base64_encode_flag == false then
|
29
|
-
@testnumkey = Base64.encode64(@testnumkey).chomp
|
30
|
-
@testnumval = Base64.encode64(@testnumval).chomp
|
31
|
-
@testkey1 = Base64.encode64(@testkey1).chomp
|
32
|
-
@testval1 = Base64.encode64(@testval1).chomp
|
33
|
-
@testkey2 = Base64.encode64(@testkey2).chomp
|
34
|
-
@testval2 = Base64.encode64(@testval2).chomp
|
35
|
-
@testnewkey = Base64.encode64(@testnewkey).chomp
|
36
|
-
@testnewval = Base64.encode64(@testnewval).chomp
|
37
|
-
@testnewval1 = Base64.encode64(@testnewval1).chomp
|
38
|
-
@testtag = Base64.encode64(@testtag).chomp
|
39
|
-
@testnewtag = Base64.encode64(@testnewtag).chomp
|
40
|
-
@testgroup = Base64.encode64(@testgroup).chomp
|
41
|
-
@testnewgroup = Base64.encode64(@testnewgroup).chomp
|
42
|
-
@testquery1 = Base64.encode64(@testquery1).chomp
|
43
|
-
@testquery2 = Base64.encode64(@testquery2).chomp
|
44
|
-
@testnewquery = Base64.encode64(@testnewquery).chomp
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
@client = Okuyama::Client.new(:host=>'localhost', :port=>8888, :base64_encode_flag=>base64_encode_flag)
|
49
|
-
@client.debug = true
|
50
|
-
@client.remove_value(@testnumkey)
|
51
|
-
@client.remove_value(@testkey1)
|
52
|
-
@client.remove_value(@testkey2)
|
53
|
-
@client.remove_value(@testnewkey)
|
54
|
-
@client.remove_tag_from_key(@testnewtag, @testkey1)
|
55
|
-
@client.set_value(@testnumkey, @testnumval)
|
56
|
-
@client.set_value_and_create_index(@testkey1, @testval1, :tags=>[@testtag], :group=>@testgroup, :min_n=>1, :max_n=>3)
|
57
|
-
@client.set_value(@testkey2, @testval2, @testtag)
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
after :each do
|
62
|
-
@client.close
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "set_value_and_create_index(key, val, :tags=>tags, :group=>group, :min_n=>min_n, :max_n=>max_n)" do
|
66
|
-
describe "when key exists," do
|
67
|
-
it "should success" do
|
68
|
-
result = @client.set_value_and_create_index(@testkey1, @testval1, :tags=>[@testtag], :group=>@testgroup, :min_n=>1, :max_n=>3)
|
69
|
-
result.should be_true
|
70
|
-
end
|
71
|
-
end
|
72
|
-
describe "when key does not exist," do
|
73
|
-
it "should success" do
|
74
|
-
result = @client.set_value_and_create_index(@testnewkey, @testnewval, :tags=>[@testnewtag], :group=>@testnewgroup, :min_n=>1, :max_n=>3)
|
75
|
-
result.should be_true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "search_value(query)" do
|
81
|
-
describe "when key exists," do
|
82
|
-
it "should return keys" do
|
83
|
-
result = @client.search_value(@testquery1)
|
84
|
-
result.sort!
|
85
|
-
result.should == [@testkey1]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
describe "when key does not exist," do
|
89
|
-
it "should return []" do
|
90
|
-
result = @client.search_value(@testnewquery)
|
91
|
-
result.should == []
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "search_value(query, :condition=>:and, :group=>group, :nsize=>nsize)" do
|
97
|
-
if false then
|
98
|
-
describe "when key exists," do
|
99
|
-
it "should return keys" do
|
100
|
-
result = @client.search_value([@testquery1, @testquery2], :condition=>:and, :group=>@testgroup, :nsize=>3)
|
101
|
-
result.sort!
|
102
|
-
result.should == ['testkey1']
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
describe "when key does not exist," do
|
107
|
-
it "should return []" do
|
108
|
-
result = @client.search_value([@testquery1, @testnewquery], :condition=>:and, :group=>@testgroup, :nsize=>3)
|
109
|
-
result.should == []
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "search_value(query, :condition=>:or, :group=>group, :nsize=>nsize)" do
|
115
|
-
if false then
|
116
|
-
describe "when key exists," do
|
117
|
-
it "should return keys" do
|
118
|
-
result = @client.search_value([@testquery1, @testquery2], :condition=>:or, :group=>@testgroup, :nsize=>3)
|
119
|
-
result.sort!
|
120
|
-
result.should == ['testkey1']
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
describe "when key does not exist," do
|
125
|
-
it "should return []" do
|
126
|
-
result = @client.search_value([@testnewquery, @testnewquery], :condition=>:or, :group=>@testgroup, :nsize=>3)
|
127
|
-
result.should == []
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|