opennebula-augeas 0.6.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +502 -0
- data/NEWS +52 -0
- data/README.rdoc +94 -0
- data/Rakefile +93 -0
- data/ext/augeas/_augeas.c +546 -0
- data/ext/augeas/_augeas.h +48 -0
- data/ext/augeas/extconf.rb +48 -0
- data/lib/augeas.rb +393 -0
- data/tests/root/etc/group +26 -0
- data/tests/root/etc/hosts +6 -0
- data/tests/root/etc/inittab +53 -0
- data/tests/root/etc/ssh/sshd_config +2 -0
- data/tests/tc_augeas.rb +551 -0
- metadata +93 -0
data/tests/tc_augeas.rb
ADDED
@@ -0,0 +1,551 @@
|
|
1
|
+
##
|
2
|
+
# Augeas tests
|
3
|
+
#
|
4
|
+
# Copyright (C) 2011 Red Hat Inc.
|
5
|
+
# Copyright (C) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
6
|
+
#
|
7
|
+
# This library is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU Lesser General Public
|
9
|
+
# License as published by the Free Software Foundation; either
|
10
|
+
# version 2.1 of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This library is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
# Lesser General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Lesser General Public
|
18
|
+
# License along with this library; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
#
|
21
|
+
# Authors: David Lutterkort <dlutter@redhat.com>
|
22
|
+
# Ionuț Arțăriși <iartarisi@suse.cz>
|
23
|
+
##
|
24
|
+
|
25
|
+
require 'test/unit'
|
26
|
+
|
27
|
+
TOPDIR = File::expand_path(File::join(File::dirname(__FILE__), ".."))
|
28
|
+
|
29
|
+
$:.unshift(File::join(TOPDIR, "lib"))
|
30
|
+
$:.unshift(File::join(TOPDIR, "ext", "augeas"))
|
31
|
+
|
32
|
+
require 'augeas'
|
33
|
+
require 'fileutils'
|
34
|
+
|
35
|
+
class TestAugeas < Test::Unit::TestCase
|
36
|
+
|
37
|
+
SRC_ROOT = File::expand_path(File::join(TOPDIR, "tests", "root")) + "/."
|
38
|
+
TST_ROOT = File::expand_path(File::join(TOPDIR, "build", "root")) + "/"
|
39
|
+
|
40
|
+
def test_basics
|
41
|
+
aug = aug_create(:save_mode => :newfile)
|
42
|
+
assert_equal("newfile", aug.get("/augeas/save"))
|
43
|
+
assert_equal(TST_ROOT, aug.get("/augeas/root"))
|
44
|
+
|
45
|
+
assert(aug.exists("/augeas/root"))
|
46
|
+
assert_not_nil(aug.get("/augeas/root"))
|
47
|
+
node = "/ruby/test/node"
|
48
|
+
assert_nothing_raised {
|
49
|
+
aug.set(node, "value")
|
50
|
+
}
|
51
|
+
assert_equal("value", aug.get(node))
|
52
|
+
assert_nothing_raised {
|
53
|
+
aug.clear(node)
|
54
|
+
}
|
55
|
+
assert_equal(nil, aug.get(node))
|
56
|
+
m = aug.match("/*")
|
57
|
+
["/augeas", "/ruby"].each do |p|
|
58
|
+
assert(m.include?(p))
|
59
|
+
assert(aug.exists(p))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_no_new
|
64
|
+
assert_raise NoMethodError do
|
65
|
+
Augeas.new
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_create_unknown_argument
|
70
|
+
assert_raise ArgumentError do
|
71
|
+
Augeas::create(:bogus => false)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_create_invalid_save_mode
|
76
|
+
assert_raise ArgumentError do
|
77
|
+
Augeas::create(:save_mode => :bogus)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_create_block
|
82
|
+
foo = nil
|
83
|
+
Augeas::create do |aug|
|
84
|
+
aug.set('/foo', 'bar')
|
85
|
+
foo = aug.get('/foo')
|
86
|
+
end
|
87
|
+
assert_equal(foo, 'bar')
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_close
|
91
|
+
aug = Augeas::create(:root => "/tmp", :save_mode => :newfile)
|
92
|
+
assert_equal("newfile", aug.get("/augeas/save"))
|
93
|
+
aug.close
|
94
|
+
|
95
|
+
assert_raise(SystemCallError) {
|
96
|
+
aug.get("/augeas/save")
|
97
|
+
}
|
98
|
+
|
99
|
+
assert_raise(SystemCallError) {
|
100
|
+
aug.close
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_mv
|
105
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
106
|
+
aug.set("/a/b", "value")
|
107
|
+
aug.mv("/a/b", "/x/y")
|
108
|
+
assert_equal("value", aug.get("/x/y"))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_mv_descendent_error
|
113
|
+
aug = aug_create
|
114
|
+
aug.set("/foo", "bar")
|
115
|
+
assert_raises(Augeas::DescendantError) {aug.mv("/foo", "/foo/bar/baz")}
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_mv_multiple_matches_error
|
119
|
+
aug = aug_create
|
120
|
+
aug.set("/foo/bar", "bar")
|
121
|
+
aug.set("/foo/baz", "baz")
|
122
|
+
assert_raises(Augeas::MultipleMatchesError) {aug.mv("/foo/*", "/qux")}
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_mv_invalid_path_error
|
126
|
+
aug = aug_create
|
127
|
+
assert_raises(Augeas::InvalidPathError) {aug.mv("/foo", "[]")}
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_mv_no_match_error
|
131
|
+
aug = aug_create
|
132
|
+
assert_raises(Augeas::NoMatchError) {aug.mv("/nonexistent", "/")}
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_mv_mutiple_dest_error
|
136
|
+
aug = aug_create
|
137
|
+
aug.set("/foo", "bar")
|
138
|
+
assert_raises(Augeas::CommandExecutionError) {aug.mv("/foo", "/bar/baz/*")}
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_load
|
142
|
+
aug = aug_create(:no_load => true)
|
143
|
+
assert_equal([], aug.match("/files/etc/*"))
|
144
|
+
aug.rm("/augeas/load/*");
|
145
|
+
assert_nothing_raised {
|
146
|
+
aug.load
|
147
|
+
}
|
148
|
+
assert_equal([], aug.match("/files/etc/*"))
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_load_bad_lens
|
152
|
+
aug = aug_create(:no_load => true)
|
153
|
+
aug.transform(:lens => "bad_lens", :incl => "irrelevant")
|
154
|
+
assert_raises(Augeas::LensNotFoundError) { aug.load }
|
155
|
+
assert_equal "Can not find lens bad_lens", aug.error[:details]
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_transform
|
159
|
+
aug = aug_create(:no_load => true)
|
160
|
+
aug.clear_transforms
|
161
|
+
aug.transform(:lens => "Hosts.lns",
|
162
|
+
:incl => "/etc/hosts")
|
163
|
+
assert_raise(ArgumentError) {
|
164
|
+
aug.transform(:name => "Fstab",
|
165
|
+
:incl => [ "/etc/fstab" ],
|
166
|
+
:excl => [ "*~", "*.rpmnew" ])
|
167
|
+
}
|
168
|
+
aug.transform(:lens => "Inittab.lns",
|
169
|
+
:incl => "/etc/inittab")
|
170
|
+
aug.transform(:lens => "Fstab.lns",
|
171
|
+
:incl => "/etc/fstab*",
|
172
|
+
:excl => "*~")
|
173
|
+
assert_equal(["/augeas/load/Fstab", "/augeas/load/Fstab/excl",
|
174
|
+
"/augeas/load/Fstab/incl", "/augeas/load/Fstab/lens",
|
175
|
+
"/augeas/load/Hosts", "/augeas/load/Hosts/incl",
|
176
|
+
"/augeas/load/Hosts/lens", "/augeas/load/Inittab",
|
177
|
+
"/augeas/load/Inittab/incl",
|
178
|
+
"/augeas/load/Inittab/lens"],
|
179
|
+
aug.match("/augeas/load//*").sort)
|
180
|
+
aug.load
|
181
|
+
assert_equal(["/files/etc/hosts", "/files/etc/inittab"],
|
182
|
+
aug.match("/files/etc/*").sort)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_transform_invalid_path
|
186
|
+
aug = aug_create
|
187
|
+
assert_raises (Augeas::InvalidPathError) {
|
188
|
+
aug.transform :lens => '//', :incl => 'foo' }
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_clear_transforms
|
192
|
+
aug = aug_create
|
193
|
+
assert_not_equal [], aug.match("/augeas/load/*")
|
194
|
+
aug.clear_transforms
|
195
|
+
assert_equal [], aug.match("/augeas/load/*")
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_clear
|
199
|
+
aug = aug_create
|
200
|
+
aug.set("/foo/bar", "baz")
|
201
|
+
aug.clear("/foo/bar")
|
202
|
+
assert_equal aug.get("/foo/bar"), nil
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_rm
|
206
|
+
aug = aug_create
|
207
|
+
aug.set("/foo/bar", "baz")
|
208
|
+
assert aug.get("/foo/bar")
|
209
|
+
assert_equal 2, aug.rm("/foo")
|
210
|
+
assert_nil aug.get("/foo")
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_rm_invalid_path
|
214
|
+
aug = aug_create
|
215
|
+
assert_raises(Augeas::InvalidPathError) { aug.rm('//') }
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_defvar
|
219
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
220
|
+
aug.set("/a/b", "bval")
|
221
|
+
aug.set("/a/c", "cval")
|
222
|
+
assert aug.defvar("var", "/a/b")
|
223
|
+
assert_equal(["/a/b"], aug.match("$var"))
|
224
|
+
assert aug.defvar("var", nil)
|
225
|
+
assert_raises(Augeas::InvalidPathError) {
|
226
|
+
aug.match("$var")
|
227
|
+
}
|
228
|
+
assert_raises(Augeas::InvalidPathError) {
|
229
|
+
aug.defvar("var", "/foo/")
|
230
|
+
}
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_insert_before
|
235
|
+
aug = aug_create
|
236
|
+
aug.set("/parent/child", "foo")
|
237
|
+
aug.insert("/parent/child", "sibling", true)
|
238
|
+
assert_equal ["/parent/sibling", "/parent/child"], aug.match("/parent/*")
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_insert_after
|
242
|
+
aug = aug_create
|
243
|
+
aug.set("/parent/child", "foo")
|
244
|
+
aug.insert("/parent/child", "sibling", false)
|
245
|
+
assert_equal ["/parent/child", "/parent/sibling"], aug.match("/parent/*")
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_insert_no_match
|
249
|
+
aug = aug_create
|
250
|
+
assert_raises (Augeas::NoMatchError) { aug.insert "foo", "bar", "baz" }
|
251
|
+
end
|
252
|
+
|
253
|
+
def test_insert_invalid_path
|
254
|
+
aug = aug_create
|
255
|
+
assert_raises (Augeas::InvalidPathError) { aug.insert "//", "bar", "baz" }
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_insert_too_many_matches
|
259
|
+
aug = aug_create
|
260
|
+
assert_raises (Augeas::MultipleMatchesError) { aug.insert "/*", "a", "b" }
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_match
|
264
|
+
aug = aug_create
|
265
|
+
aug.set("/foo/bar", "baz")
|
266
|
+
aug.set("/foo/baz", "qux")
|
267
|
+
aug.set("/foo/qux", "bar")
|
268
|
+
|
269
|
+
assert_equal(["/foo/bar", "/foo/baz", "/foo/qux"], aug.match("/foo/*"))
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_match_empty_list
|
273
|
+
aug = aug_create
|
274
|
+
assert_equal([], aug.match("/nonexistent"))
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_match_invalid_path
|
278
|
+
aug = aug_create
|
279
|
+
assert_raises(Augeas::InvalidPathError) { aug.match('//') }
|
280
|
+
end
|
281
|
+
|
282
|
+
def test_save
|
283
|
+
aug = aug_create
|
284
|
+
aug.set("/files/etc/hosts/1/garbage", "trash")
|
285
|
+
assert_raises(Augeas::CommandExecutionError) { aug.save }
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_save_tree_error
|
289
|
+
aug = aug_create(:no_load => true)
|
290
|
+
aug.set("/files/etc/sysconfig/iptables", "bad")
|
291
|
+
assert_raises(Augeas::CommandExecutionError) {aug.save}
|
292
|
+
assert aug.get("/augeas/files/etc/sysconfig/iptables/error")
|
293
|
+
assert_equal("No such file or directory",
|
294
|
+
aug.get("/augeas/files/etc/sysconfig/iptables/error/message"))
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_set_invalid_path
|
298
|
+
aug = aug_create
|
299
|
+
assert_raises(Augeas::InvalidPathError) { aug.set("files/etc//", nil) }
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_set_multiple_matches_error
|
303
|
+
aug = aug_create
|
304
|
+
# for some reason Augeas does not set aug_error for this,
|
305
|
+
# but just returns -1 from aug_set. Should raise Augeas::MultipleMatchesError instead.
|
306
|
+
assert_raises(Augeas::CommandExecutionError) { aug.set("files/etc/*", nil) }
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_set
|
310
|
+
aug = aug_create
|
311
|
+
aug.set("/files/etc/group/disk/user[last()+1]",["user1","user2"])
|
312
|
+
assert_equal(aug.get("/files/etc/group/disk/user[1]"), "root")
|
313
|
+
assert_equal(aug.get("/files/etc/group/disk/user[2]"), "user1")
|
314
|
+
assert_equal(aug.get("/files/etc/group/disk/user[3]"), "user2")
|
315
|
+
|
316
|
+
aug.set("/files/etc/group/new_group/user[last()+1]",
|
317
|
+
"nuser1",["nuser2","nuser3"])
|
318
|
+
assert_equal(aug.get("/files/etc/group/new_group/user[1]"), "nuser1")
|
319
|
+
assert_equal(aug.get("/files/etc/group/new_group/user[2]"), "nuser2")
|
320
|
+
assert_equal(aug.get("/files/etc/group/new_group/user[3]"), "nuser3")
|
321
|
+
|
322
|
+
aug.rm("/files/etc/group/disk/user")
|
323
|
+
aug.set("/files/etc/group/disk/user[last()+1]", "testuser")
|
324
|
+
assert_equal(aug.get("/files/etc/group/disk/user"), "testuser")
|
325
|
+
|
326
|
+
aug.rm("/files/etc/group/disk/user")
|
327
|
+
aug.set("/files/etc/group/disk/user[last()+1]", nil)
|
328
|
+
assert_equal(aug.get("/files/etc/group/disk/user"), nil)
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_setm_invalid_path
|
332
|
+
aug = aug_create
|
333
|
+
assert_raises (Augeas::InvalidPathError) { aug.setm("[]", "bar", "baz") }
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_exists
|
337
|
+
aug = aug_create
|
338
|
+
assert_equal false, aug.exists("/foo")
|
339
|
+
aug.set("/foo", "bar")
|
340
|
+
assert aug.exists("/foo")
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_exists_invalid_path_error
|
344
|
+
aug = aug_create
|
345
|
+
assert_raises(Augeas::InvalidPathError) {aug.exists("[]")}
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_get_multiple_matches_error
|
349
|
+
aug = aug_create
|
350
|
+
|
351
|
+
# Cause an error
|
352
|
+
assert_raises (Augeas::MultipleMatchesError) {
|
353
|
+
aug.get("/files/etc/hosts/*") }
|
354
|
+
|
355
|
+
err = aug.error
|
356
|
+
assert_equal(Augeas::EMMATCH, err[:code])
|
357
|
+
assert err[:message]
|
358
|
+
assert err[:details]
|
359
|
+
assert err[:minor].nil?
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_get_invalid_path
|
363
|
+
aug = aug_create
|
364
|
+
assert_raises (Augeas::InvalidPathError) { aug.get("//") }
|
365
|
+
|
366
|
+
err = aug.error
|
367
|
+
assert_equal(Augeas::EPATHX, err[:code])
|
368
|
+
assert err[:message]
|
369
|
+
assert err[:details]
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_defvar_invalid_path
|
373
|
+
aug = aug_create
|
374
|
+
assert_raises(Augeas::InvalidPathError) { aug.defvar('var', 'F#@!$#@') }
|
375
|
+
end
|
376
|
+
|
377
|
+
def test_defnode
|
378
|
+
aug = aug_create
|
379
|
+
assert aug.defnode("x", "/files/etc/hosts/*[ipaddr = '127.0.0.1']", nil)
|
380
|
+
assert_equal(["/files/etc/hosts/1"], aug.match("$x"))
|
381
|
+
end
|
382
|
+
|
383
|
+
def test_defnode_invalid_path
|
384
|
+
aug = aug_create
|
385
|
+
assert_raises (Augeas::InvalidPathError) { aug.defnode('x', '//', nil)}
|
386
|
+
end
|
387
|
+
|
388
|
+
def test_span_no_span_info
|
389
|
+
aug = aug_create
|
390
|
+
# this error should be raised because we haven't enabled the span
|
391
|
+
assert_raises(Augeas::NoSpanInfoError) {
|
392
|
+
aug.span("/files/etc/ssh/sshd_config/Protocol") }
|
393
|
+
end
|
394
|
+
|
395
|
+
def test_span_no_matches
|
396
|
+
aug = aug_create
|
397
|
+
assert_raises(Augeas::NoMatchError) { aug.span("bogus") }
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_flag_save_noop
|
401
|
+
aug = aug_create(:save_mode => :noop)
|
402
|
+
assert_equal("noop", aug.get("/augeas/save"))
|
403
|
+
end
|
404
|
+
|
405
|
+
def test_flag_no_load
|
406
|
+
aug = aug_create(:no_load => true)
|
407
|
+
assert_equal([], aug.match("/files/*"))
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_flag_no_modl_autoload
|
411
|
+
aug = aug_create(:no_modl_autoload => true)
|
412
|
+
assert_equal([], aug.match("/files/*"))
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_flag_enable_span
|
416
|
+
aug = aug_create(:enable_span => true)
|
417
|
+
assert_equal("enable", aug.get("/augeas/span"))
|
418
|
+
end
|
419
|
+
|
420
|
+
def test_setm
|
421
|
+
aug = aug_create
|
422
|
+
|
423
|
+
aug.setm("/files/etc/group/*[label() =~ regexp(\"rpc.*\")]","users", "testuser1")
|
424
|
+
assert_equal( aug.get("/files/etc/group/rpc/users"), "testuser1")
|
425
|
+
assert_equal( aug.get("/files/etc/group/rpcuser/users"), "testuser1")
|
426
|
+
|
427
|
+
aug.setm("/files/etc/group/*[label() =~ regexp(\"rpc.*\")]/users",nil, "testuser2")
|
428
|
+
assert_equal( aug.get("/files/etc/group/rpc/users"), "testuser2")
|
429
|
+
assert_equal( aug.get("/files/etc/group/rpcuser/users"), "testuser2")
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_error
|
433
|
+
aug = aug_create
|
434
|
+
|
435
|
+
# Cause an error
|
436
|
+
aug.get("/files/etc/hosts/*") rescue nil
|
437
|
+
err = aug.error
|
438
|
+
assert_equal(Augeas::EMMATCH, err[:code])
|
439
|
+
assert err[:message]
|
440
|
+
assert err[:details]
|
441
|
+
assert err[:minor].nil?
|
442
|
+
end
|
443
|
+
|
444
|
+
def test_span
|
445
|
+
aug = aug_create
|
446
|
+
|
447
|
+
assert_raises(Augeas::NoSpanInfoError) { aug.span("/files/etc/ssh/sshd_config/Protocol") }
|
448
|
+
|
449
|
+
aug.set("/augeas/span", "enable")
|
450
|
+
aug.rm("/files/etc")
|
451
|
+
aug.load
|
452
|
+
|
453
|
+
span = aug.span("/files/etc/ssh/sshd_config/Protocol")
|
454
|
+
assert_not_nil(span[:filename])
|
455
|
+
assert_equal(29..37, span[:label])
|
456
|
+
assert_equal(38..39, span[:value])
|
457
|
+
assert_equal(29..40, span[:span])
|
458
|
+
end
|
459
|
+
|
460
|
+
def test_srun
|
461
|
+
aug = aug_create
|
462
|
+
|
463
|
+
path = "/files/etc/hosts/*[canonical='localhost.localdomain']/ipaddr"
|
464
|
+
r, out = aug.srun("get #{path}\n")
|
465
|
+
assert_equal(1, r)
|
466
|
+
assert_equal("#{path} = 127.0.0.1\n", out)
|
467
|
+
|
468
|
+
assert_equal(0, aug.srun(" ")[0])
|
469
|
+
assert_raises(Augeas::CommandExecutionError) { aug.srun("foo") }
|
470
|
+
assert_raises(Augeas::CommandExecutionError) { aug.srun("set") }
|
471
|
+
assert_equal(-2, aug.srun("quit")[0])
|
472
|
+
end
|
473
|
+
|
474
|
+
def test_label
|
475
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
476
|
+
assert_equal 'augeas', aug.label('/augeas')
|
477
|
+
assert_equal 'files', aug.label('/files')
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
def test_rename
|
482
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
483
|
+
assert_raises(Augeas::InvalidLabelError) { aug.rename('/files', 'invalid/label') }
|
484
|
+
assert_equal 0, aug.rename('/nonexistent', 'label')
|
485
|
+
assert_equal ['/files'], aug.match('/files')
|
486
|
+
assert_equal 1, aug.rename('/files', 'label')
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
def test_text_store_retrieve
|
491
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
492
|
+
# text_store errors
|
493
|
+
assert_raises(Augeas::NoMatchError) { aug.text_store('Simplelines.lns', '/input', '/store') }
|
494
|
+
|
495
|
+
# text_store
|
496
|
+
aug.set('/input', "line1\nline2\n")
|
497
|
+
assert aug.text_store('Simplelines.lns', '/input', '/store')
|
498
|
+
assert_equal 'line2', aug.get('/store/2')
|
499
|
+
|
500
|
+
# text_retrieve errors
|
501
|
+
assert_raises(Augeas::NoMatchError) { aug.text_retrieve('Simplelines.lns', '/unknown', '/store', '/output') }
|
502
|
+
|
503
|
+
# text_retrieve
|
504
|
+
aug.set('/store/3', 'line3')
|
505
|
+
assert aug.text_retrieve('Simplelines.lns', '/input', '/store', '/output')
|
506
|
+
assert_equal "line1\nline2\nline3\n", aug.get('/output')
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
def test_context
|
511
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
512
|
+
aug.context = '/augeas'
|
513
|
+
assert_equal '/augeas', aug.get('/augeas/context')
|
514
|
+
assert_equal '/augeas', aug.get('context')
|
515
|
+
assert_equal '/augeas', aug.context
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_touch
|
520
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
521
|
+
assert_equal [], aug.match('/foo')
|
522
|
+
aug.touch '/foo'
|
523
|
+
assert_equal ['/foo'], aug.match('/foo')
|
524
|
+
|
525
|
+
aug.set '/foo', 'bar'
|
526
|
+
aug.touch '/foo'
|
527
|
+
assert_equal 'bar', aug.get('/foo')
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_clearm
|
532
|
+
Augeas::create(:root => "/dev/null") do |aug|
|
533
|
+
aug.set('/foo/a', '1')
|
534
|
+
aug.set('/foo/b', '2')
|
535
|
+
aug.clearm('/foo', '*')
|
536
|
+
assert_nil aug.get('/foo/a')
|
537
|
+
assert_nil aug.get('/foo/b')
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
private
|
542
|
+
def aug_create(flags={})
|
543
|
+
if File::directory?(TST_ROOT)
|
544
|
+
FileUtils::rm_rf(TST_ROOT)
|
545
|
+
end
|
546
|
+
FileUtils::mkdir_p(TST_ROOT)
|
547
|
+
FileUtils::cp_r(SRC_ROOT, TST_ROOT)
|
548
|
+
|
549
|
+
Augeas::create({:root => TST_ROOT, :loadpath => nil}.merge(flags))
|
550
|
+
end
|
551
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opennebula-augeas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.6.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Kearney
|
8
|
+
- David Lutterkort
|
9
|
+
- Dominic Cleal
|
10
|
+
- Raphaël Pinson
|
11
|
+
- Frederik Wagner
|
12
|
+
- Artem Sheremet
|
13
|
+
- Ben
|
14
|
+
- Ionuț Arțăriși Ionuț Arțăriși
|
15
|
+
- Jacob McCann
|
16
|
+
autorequire:
|
17
|
+
bindir: bin
|
18
|
+
cert_chain: []
|
19
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
type: :development
|
29
|
+
prerelease: false
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rdoc
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
type: :development
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
description: A fork of ruby-augeas (bindings for augeas) with exceptions support.
|
50
|
+
email: info@opennebula.io
|
51
|
+
executables: []
|
52
|
+
extensions:
|
53
|
+
- ext/augeas/extconf.rb
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- COPYING
|
57
|
+
- NEWS
|
58
|
+
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- ext/augeas/_augeas.c
|
61
|
+
- ext/augeas/_augeas.h
|
62
|
+
- ext/augeas/extconf.rb
|
63
|
+
- lib/augeas.rb
|
64
|
+
- tests/root/etc/group
|
65
|
+
- tests/root/etc/hosts
|
66
|
+
- tests/root/etc/inittab
|
67
|
+
- tests/root/etc/ssh/sshd_config
|
68
|
+
- tests/tc_augeas.rb
|
69
|
+
homepage: http://opennebula.io/
|
70
|
+
licenses:
|
71
|
+
- LGPL-2.1+
|
72
|
+
metadata:
|
73
|
+
source_code_uri: https://github.com/OpenNebula/ruby-augeas
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.7
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.3.1
|
88
|
+
requirements: []
|
89
|
+
rubygems_version: 3.4.10
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Ruby bindings for augeas
|
93
|
+
test_files: []
|