fraggle 0.1.1 → 0.2.0
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/README.md +32 -16
- data/lib/fraggle.rb +6 -316
- data/lib/fraggle/client.rb +325 -0
- data/lib/fraggle/emitter.rb +26 -0
- data/lib/fraggle/logger.rb +26 -0
- data/lib/fraggle/meta.rb +9 -0
- data/lib/fraggle/{proto.rb → msg.rb} +10 -2
- data/lib/fraggle/protocol.rb +47 -0
- data/lib/fraggle/request.rb +15 -0
- data/lib/fraggle/response.rb +33 -0
- data/lib/fraggle/snap.rb +43 -0
- data/lib/fraggle/test.rb +72 -0
- data/test/fraggle_client_test.rb +261 -0
- data/test/fraggle_protocol_test.rb +100 -0
- data/test/fraggle_snap_test.rb +67 -0
- metadata +20 -11
- data/test/core_test.rb +0 -215
- data/test/live_test.rb +0 -197
- data/test/reconnect_test.rb +0 -175
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'fraggle/client'
|
2
|
+
require 'fraggle/protocol'
|
3
|
+
require 'fraggle/response'
|
4
|
+
require 'fraggle/test'
|
5
|
+
|
6
|
+
class FraggleProtocolTest < Test::Unit::TestCase
|
7
|
+
include Fraggle::Test
|
8
|
+
|
9
|
+
class TestConn < Array
|
10
|
+
include Fraggle::Protocol
|
11
|
+
alias :receive_response :<<
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :cn
|
15
|
+
|
16
|
+
def setup
|
17
|
+
@cn = TestConn.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def encode(req)
|
21
|
+
data = req.encode
|
22
|
+
[data.length].pack("N") + data
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_simple
|
26
|
+
req = Fraggle::Response.new :tag => 0, :verb => V::NOOP, :flags => F::VALID
|
27
|
+
cn.receive_data(encode(req))
|
28
|
+
|
29
|
+
assert_equal [req], cn
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_multiple_single
|
33
|
+
a = Fraggle::Response.new :tag => 0, :verb => V::NOOP, :flags => F::VALID
|
34
|
+
b = Fraggle::Response.new :tag => 1, :verb => V::NOOP, :flags => F::VALID
|
35
|
+
cn.receive_data(encode(a) + encode(b))
|
36
|
+
|
37
|
+
assert_equal [a, b], cn
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_multiple_double
|
41
|
+
a = Fraggle::Response.new :tag => 0, :verb => V::NOOP, :flags => F::VALID
|
42
|
+
b = Fraggle::Response.new :tag => 1, :verb => V::NOOP, :flags => F::VALID
|
43
|
+
cn.receive_data(encode(a))
|
44
|
+
cn.receive_data(encode(b))
|
45
|
+
|
46
|
+
assert_equal [a, b], cn
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_small_chunks
|
50
|
+
req = Fraggle::Response.new :tag => 0, :verb => V::NOOP, :flags => F::VALID
|
51
|
+
|
52
|
+
bytes = encode(req) * 3
|
53
|
+
len = bytes.length
|
54
|
+
|
55
|
+
0.step(len, 1) do |i|
|
56
|
+
data = bytes.slice!(0, i)
|
57
|
+
cn.receive_data(data)
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_equal [req, req, req], cn
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_big_chunks
|
64
|
+
req = Fraggle::Response.new :tag => 0, :verb => V::NOOP, :flags => F::VALID
|
65
|
+
|
66
|
+
bytes = encode(req) * 3
|
67
|
+
len = bytes.length
|
68
|
+
|
69
|
+
0.step(len, len/2) do |i|
|
70
|
+
data = bytes.slice!(0, i)
|
71
|
+
cn.receive_data(data)
|
72
|
+
end
|
73
|
+
|
74
|
+
assert_equal [req, req, req], cn
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_send_request
|
78
|
+
c = Class.new do
|
79
|
+
include Fraggle::Client
|
80
|
+
|
81
|
+
attr_reader :data
|
82
|
+
|
83
|
+
def initialize
|
84
|
+
@data = ""
|
85
|
+
super("doozer://127.0.0.1:8046")
|
86
|
+
end
|
87
|
+
|
88
|
+
def send_data(data)
|
89
|
+
@data << data
|
90
|
+
end
|
91
|
+
end.new
|
92
|
+
|
93
|
+
req = c.noop
|
94
|
+
bytes = req.encode
|
95
|
+
head = [bytes.length].pack("N")
|
96
|
+
|
97
|
+
assert_equal head+bytes, c.data
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'fraggle/test'
|
2
|
+
require 'fraggle/snap'
|
3
|
+
|
4
|
+
class FraggleSnapTest < Test::Unit::TestCase
|
5
|
+
include Fraggle::Test
|
6
|
+
|
7
|
+
attr_reader :c, :blk
|
8
|
+
|
9
|
+
def setup
|
10
|
+
cl = TestClient.new("doozer://127.0.0.1:8046")
|
11
|
+
@c = Fraggle::Snap.new(1, cl)
|
12
|
+
@blk = Blk.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_get
|
16
|
+
req = c.get("/ping", &blk)
|
17
|
+
|
18
|
+
assert_sent req.tag, :verb => V::GET, :id => 1, :path => "/ping"
|
19
|
+
assert_recv reply(req.tag)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_stat
|
23
|
+
req = c.stat("/ping", &blk)
|
24
|
+
|
25
|
+
assert_sent req.tag, :verb => V::STAT, :id => 1, :path => "/ping"
|
26
|
+
assert_recv reply(req.tag)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_getdir
|
30
|
+
req = c.getdir("/test", &blk)
|
31
|
+
|
32
|
+
assert_sent req.tag, :verb => V::GETDIR, :path => "/test", :id => 1
|
33
|
+
assert_recv reply(req.tag)
|
34
|
+
|
35
|
+
req = c.getdir("/test", 1, 2, &blk)
|
36
|
+
|
37
|
+
assert_sent req.tag, :verb => V::GETDIR, :path => "/test", :offset => 1, :limit => 2, :id => 1
|
38
|
+
assert_recv reply(req.tag)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_walk
|
42
|
+
req = c.walk("/letters/*", &blk)
|
43
|
+
|
44
|
+
assert_sent req.tag, :verb => V::WALK, :id => 1, :path => "/letters/*"
|
45
|
+
assert_recv reply(req.tag)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_other
|
49
|
+
req = c.noop(&blk)
|
50
|
+
|
51
|
+
assert_sent req.tag, :verb => V::NOOP
|
52
|
+
assert_recv reply(req.tag)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_snap
|
56
|
+
b = nil
|
57
|
+
a = c.snap do |sn|
|
58
|
+
b = sn.get("/ping")
|
59
|
+
end
|
60
|
+
|
61
|
+
reply(a.tag, :id => 99)
|
62
|
+
|
63
|
+
assert_sent a.tag, :verb => V::SNAP
|
64
|
+
assert_sent b.tag, :verb => V::GET, :id => 99, :path => "/ping"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Blake Mizerany
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-02-08 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,11 +43,20 @@ extra_rdoc_files:
|
|
43
43
|
files:
|
44
44
|
- LICENSE
|
45
45
|
- README.md
|
46
|
-
- lib/fraggle/
|
46
|
+
- lib/fraggle/client.rb
|
47
|
+
- lib/fraggle/emitter.rb
|
48
|
+
- lib/fraggle/logger.rb
|
49
|
+
- lib/fraggle/meta.rb
|
50
|
+
- lib/fraggle/msg.rb
|
51
|
+
- lib/fraggle/protocol.rb
|
52
|
+
- lib/fraggle/request.rb
|
53
|
+
- lib/fraggle/response.rb
|
54
|
+
- lib/fraggle/snap.rb
|
55
|
+
- lib/fraggle/test.rb
|
47
56
|
- lib/fraggle.rb
|
48
|
-
- test/
|
49
|
-
- test/
|
50
|
-
- test/
|
57
|
+
- test/fraggle_client_test.rb
|
58
|
+
- test/fraggle_protocol_test.rb
|
59
|
+
- test/fraggle_snap_test.rb
|
51
60
|
has_rdoc: true
|
52
61
|
homepage: http://github.com/bmizerany/fraggle
|
53
62
|
licenses: []
|
@@ -84,6 +93,6 @@ signing_key:
|
|
84
93
|
specification_version: 2
|
85
94
|
summary: A Ruby/EventMachine Client for Doozer
|
86
95
|
test_files:
|
87
|
-
- test/
|
88
|
-
- test/
|
89
|
-
- test/
|
96
|
+
- test/fraggle_client_test.rb
|
97
|
+
- test/fraggle_protocol_test.rb
|
98
|
+
- test/fraggle_snap_test.rb
|
data/test/core_test.rb
DELETED
@@ -1,215 +0,0 @@
|
|
1
|
-
require 'fraggle'
|
2
|
-
|
3
|
-
##
|
4
|
-
# This is used to test core functionality that the live integration tests will
|
5
|
-
# rely on.
|
6
|
-
class FakeConn
|
7
|
-
include Fraggle
|
8
|
-
|
9
|
-
attr_reader :sent, :cbx
|
10
|
-
attr_accessor :tag
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@sent = ""
|
14
|
-
super("127.0.0.1", :assemble => false)
|
15
|
-
post_init
|
16
|
-
end
|
17
|
-
|
18
|
-
def send_data(data)
|
19
|
-
@sent << data
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class CoreTest < Test::Unit::TestCase
|
24
|
-
|
25
|
-
attr_reader :c
|
26
|
-
|
27
|
-
V = Fraggle::Request::Verb
|
28
|
-
F = Fraggle::Response::Flag
|
29
|
-
|
30
|
-
def setup
|
31
|
-
@c = FakeConn.new
|
32
|
-
end
|
33
|
-
|
34
|
-
def reply(attrs={})
|
35
|
-
attrs[:tag] = c.tag
|
36
|
-
attrs[:flags] ||= 0
|
37
|
-
attrs[:flags] |= F::VALID
|
38
|
-
res = Fraggle::Response.new(attrs)
|
39
|
-
c.receive_response(res)
|
40
|
-
res
|
41
|
-
end
|
42
|
-
|
43
|
-
def reply!(attrs={})
|
44
|
-
attrs[:flags] = F::DONE
|
45
|
-
reply(attrs)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_sending_data
|
49
|
-
c.call(V::NOOP)
|
50
|
-
|
51
|
-
req = Fraggle::Request.new(
|
52
|
-
:tag => c.tag,
|
53
|
-
:verb => V::NOOP
|
54
|
-
)
|
55
|
-
|
56
|
-
buf = req.encode
|
57
|
-
pre = [buf.length].pack("N")
|
58
|
-
|
59
|
-
assert_equal pre+buf, c.sent
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_receive_small_buffered_data
|
63
|
-
count = 0
|
64
|
-
|
65
|
-
tag = c.call(V::WATCH, :path => "**") do |e|
|
66
|
-
count += 1
|
67
|
-
end
|
68
|
-
|
69
|
-
res = Fraggle::Response.new(
|
70
|
-
:tag => tag,
|
71
|
-
:flags => F::VALID
|
72
|
-
)
|
73
|
-
|
74
|
-
exp = 10
|
75
|
-
buf = res.encode
|
76
|
-
pre = [buf.length].pack("N")
|
77
|
-
bytes = (pre+buf)*exp
|
78
|
-
|
79
|
-
# Chunk bytes to receive_data in some arbitrary size
|
80
|
-
0.step(bytes.length, 3) do |n|
|
81
|
-
c.receive_data(bytes.slice!(0, n))
|
82
|
-
end
|
83
|
-
|
84
|
-
assert_equal 10, count
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_receive_large_buffered_data
|
88
|
-
count = 0
|
89
|
-
|
90
|
-
tag = c.call(V::WATCH, :path => "**") do |e|
|
91
|
-
count += 1
|
92
|
-
end
|
93
|
-
|
94
|
-
res = Fraggle::Response.new(
|
95
|
-
:tag => tag,
|
96
|
-
:flags => F::VALID
|
97
|
-
)
|
98
|
-
|
99
|
-
exp = 10
|
100
|
-
buf = res.encode
|
101
|
-
pre = [buf.length].pack("N")
|
102
|
-
bytes = (pre+buf)*exp
|
103
|
-
|
104
|
-
c.receive_data(bytes)
|
105
|
-
|
106
|
-
assert_equal 10, count
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_callback_without_done
|
110
|
-
valid = lambda do |e|
|
111
|
-
assert_kind_of Fraggle::Response, e
|
112
|
-
end
|
113
|
-
|
114
|
-
done = lambda do |e|
|
115
|
-
assert false, "Unreachable"
|
116
|
-
end
|
117
|
-
|
118
|
-
tests = [valid, done]
|
119
|
-
|
120
|
-
c.call(V::NOOP) do |e|
|
121
|
-
tests.shift.call(e)
|
122
|
-
end
|
123
|
-
reply!
|
124
|
-
|
125
|
-
assert_equal 1, tests.length
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_callback_with_done
|
129
|
-
valid = lambda do |e, done|
|
130
|
-
assert_kind_of Fraggle::Response, e
|
131
|
-
assert_equal false, done
|
132
|
-
end
|
133
|
-
|
134
|
-
done = lambda do |e, done|
|
135
|
-
assert_nil e
|
136
|
-
assert_equal true, done
|
137
|
-
end
|
138
|
-
|
139
|
-
tests = [valid, done]
|
140
|
-
|
141
|
-
c.call(V::NOOP) do |e, done|
|
142
|
-
tests.shift.call(e, done)
|
143
|
-
end
|
144
|
-
|
145
|
-
reply!
|
146
|
-
assert tests.empty?
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_no_callback
|
150
|
-
c.call(V::NOOP)
|
151
|
-
|
152
|
-
assert_nothing_raised do
|
153
|
-
reply!
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_no_callback_gc
|
158
|
-
c.call(V::NOOP)
|
159
|
-
reply!
|
160
|
-
|
161
|
-
assert ! c.cbx.has_key?(1)
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_callback_gc
|
165
|
-
c.call(V::NOOP) {}
|
166
|
-
reply
|
167
|
-
|
168
|
-
assert c.cbx.has_key?(c.tag)
|
169
|
-
|
170
|
-
reply!
|
171
|
-
|
172
|
-
assert ! c.cbx.has_key?(c.tag)
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_call_returns_tag
|
176
|
-
assert_equal 0, c.call(V::NOOP)
|
177
|
-
assert_equal 1, c.call(V::NOOP)
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_call_increments_tag
|
181
|
-
c.call(V::NOOP)
|
182
|
-
assert_equal 0, c.tag
|
183
|
-
c.call(V::NOOP)
|
184
|
-
assert_equal 1, c.tag
|
185
|
-
c.call(V::NOOP)
|
186
|
-
assert_equal 2, c.tag
|
187
|
-
c.call(V::NOOP)
|
188
|
-
assert_equal 3, c.tag
|
189
|
-
c.call(V::NOOP)
|
190
|
-
assert_equal 4, c.tag
|
191
|
-
c.call(V::NOOP)
|
192
|
-
assert_equal 5, c.tag
|
193
|
-
c.call(V::NOOP)
|
194
|
-
assert_equal 6, c.tag
|
195
|
-
c.call(V::NOOP)
|
196
|
-
assert_equal 7, c.tag
|
197
|
-
c.call(V::NOOP)
|
198
|
-
assert_equal 8, c.tag
|
199
|
-
c.call(V::NOOP)
|
200
|
-
assert_equal 9, c.tag
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_no_overlap_in_tags
|
204
|
-
c.cbx[0] = Proc.new {}
|
205
|
-
assert_equal 1, c.call(V::NOOP)
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_rollover_tag_when_maxed_out
|
209
|
-
c.tag = Fraggle::MaxInt32
|
210
|
-
c.call(V::NOOP)
|
211
|
-
|
212
|
-
assert_equal Fraggle::MinInt32, c.tag
|
213
|
-
end
|
214
|
-
|
215
|
-
end
|
data/test/live_test.rb
DELETED
@@ -1,197 +0,0 @@
|
|
1
|
-
require 'fraggle'
|
2
|
-
|
3
|
-
class LiveTest < Test::Unit::TestCase
|
4
|
-
def start(timeout=1, &blk)
|
5
|
-
EM.run do
|
6
|
-
if timeout > 0
|
7
|
-
EM.add_timer(timeout) { fail "Test timeout!" }
|
8
|
-
end
|
9
|
-
|
10
|
-
c = Fraggle.connect(
|
11
|
-
"127.0.0.1:8046",
|
12
|
-
:assemble => false
|
13
|
-
)
|
14
|
-
|
15
|
-
blk.call(c)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def stop
|
20
|
-
EM.stop
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_get
|
24
|
-
start do |c|
|
25
|
-
c.get "/ping" do |e|
|
26
|
-
assert e.ok?, e.err_detail
|
27
|
-
assert e.cas > 0
|
28
|
-
assert_equal "pong", e.value
|
29
|
-
stop
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_set
|
35
|
-
start do |c|
|
36
|
-
c.set "/test-set", "a", :clobber do |ea|
|
37
|
-
assert ea.ok?, ea.err_detail
|
38
|
-
assert ea.cas > 0
|
39
|
-
assert_nil ea.value
|
40
|
-
|
41
|
-
c.get "/test-set" do |eb|
|
42
|
-
assert eb.ok?, eb.err_detail
|
43
|
-
assert_equal "a", eb.value
|
44
|
-
stop
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_del
|
51
|
-
start do |c|
|
52
|
-
c.set "/test-del", "a", :clobber do |e|
|
53
|
-
assert e.ok?, e.err_detail
|
54
|
-
|
55
|
-
c.del("/test-del", e.cas) do |de|
|
56
|
-
assert de.ok?, de.err_detail
|
57
|
-
stop
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_error
|
64
|
-
start do |c|
|
65
|
-
c.set "/test-error", "a", :clobber do |ea|
|
66
|
-
assert ! ea.mismatch?
|
67
|
-
assert ea.ok?, ea.err_detail
|
68
|
-
c.set "/test-error", "b", :missing do |eb|
|
69
|
-
assert eb.mismatch?, eb.err_detail
|
70
|
-
stop
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_watch
|
77
|
-
start do |c|
|
78
|
-
count = 0
|
79
|
-
c.watch("/**") do |e|
|
80
|
-
assert e.ok?, e.err_detail
|
81
|
-
|
82
|
-
count += 1
|
83
|
-
if count == 9
|
84
|
-
stop
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
10.times do
|
89
|
-
EM.next_tick { c.set("/test-watch", "something", :clobber) }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_snap
|
95
|
-
start do |c|
|
96
|
-
c.set "/test-snap", "a", :clobber do |e|
|
97
|
-
assert e.ok?, e.err_detail
|
98
|
-
|
99
|
-
c.snap do |se|
|
100
|
-
assert se.ok?, se.err_detail
|
101
|
-
assert_not_equal 0, se.id
|
102
|
-
|
103
|
-
c.set "/test-snap", "b", :clobber do |e|
|
104
|
-
assert e.ok?, e.err_detail
|
105
|
-
|
106
|
-
c.get "/test-snap", se.id do |ge|
|
107
|
-
assert ge.ok?, ge.err_detail
|
108
|
-
assert_equal "a", ge.value
|
109
|
-
stop
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# TODO: ??? Shouldn't a deleted snapid produce an error on read?
|
118
|
-
def test_delsnap
|
119
|
-
start do |c|
|
120
|
-
c.snap do |se|
|
121
|
-
assert se.ok?, se.err_detail
|
122
|
-
assert_not_equal 0, se.id
|
123
|
-
|
124
|
-
|
125
|
-
c.delsnap se.id do |de|
|
126
|
-
assert de.ok?, de.err_detail
|
127
|
-
|
128
|
-
c.get "/ping", se.id do |ge|
|
129
|
-
assert ! ge.ok?, ge.err_detail
|
130
|
-
stop
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_noop
|
138
|
-
start do |c|
|
139
|
-
c.noop do |e|
|
140
|
-
assert e.ok?, e.err_detail
|
141
|
-
stop
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_cancel
|
147
|
-
start do |c|
|
148
|
-
tag = c.watch("/test-cancel") do |e, done|
|
149
|
-
if ! done
|
150
|
-
assert e.ok?, e.err_detail
|
151
|
-
end
|
152
|
-
|
153
|
-
if done
|
154
|
-
stop
|
155
|
-
end
|
156
|
-
|
157
|
-
c.cancel(tag)
|
158
|
-
end
|
159
|
-
|
160
|
-
c.set("/test-cancel", "a", :clobber)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_walk
|
165
|
-
start do |c|
|
166
|
-
|
167
|
-
exp = [
|
168
|
-
["/test-walk/1", "a"],
|
169
|
-
["/test-walk/2", "b"],
|
170
|
-
["/test-walk/3", "c"]
|
171
|
-
]
|
172
|
-
|
173
|
-
n = exp.length
|
174
|
-
|
175
|
-
exp.each do |path, val|
|
176
|
-
c.set path, val, :clobber do |e|
|
177
|
-
assert e.ok?, e.err_detail
|
178
|
-
n -= 1
|
179
|
-
|
180
|
-
if n == 0
|
181
|
-
items = []
|
182
|
-
c.walk "/test-walk/*" do |e, done|
|
183
|
-
if done
|
184
|
-
assert_equal exp, items
|
185
|
-
stop
|
186
|
-
else
|
187
|
-
items << [e.path, e.value]
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|