reapack-index 1.0beta2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,817 @@
1
+ require File.expand_path '../helper', __FILE__
2
+
3
+ class TestIndex < MiniTest::Test
4
+ def setup
5
+ @real_path = File.expand_path '../data/index.xml', __FILE__
6
+ @dummy_path = Dir::Tmpname.create('index.xml') {|path| path }
7
+
8
+ @commit = '399f5609cff3e6fd92b5542d444fbf86da0443c6'
9
+ end
10
+
11
+ def teardown
12
+ File.delete @dummy_path if File.exists? @dummy_path
13
+ end
14
+
15
+ def test_type_of
16
+ assert_nil ReaPack::Index.type_of('src/main.cpp')
17
+
18
+ assert_equal :script, ReaPack::Index.type_of('Track/instrument_track.lua')
19
+ assert_equal :script, ReaPack::Index.type_of('Track/instrument_track.eel')
20
+ end
21
+
22
+ def test_source_for
23
+ assert_nil ReaPack::Index.source_for('http://google.com')
24
+
25
+ assert_equal 'https://github.com/User/Repo/raw/$commit/$path',
26
+ ReaPack::Index.source_for('git@github.com:User/Repo.git')
27
+
28
+ assert_equal 'https://github.com/User/Repo/raw/$commit/$path',
29
+ ReaPack::Index.source_for('https://github.com/User/Repo.git')
30
+ end
31
+
32
+ def test_validate_standalone
33
+ refute_nil ReaPack::Index.validate_file @real_path # not a valid script
34
+ end
35
+
36
+ def test_validate_noindex
37
+ assert_nil ReaPack::Index.validate_file \
38
+ File.expand_path '../data/noindex.lua', __FILE__
39
+ end
40
+
41
+ def test_read
42
+ index = ReaPack::Index.new @real_path
43
+
44
+ assert_equal 1, index.version
45
+ assert_equal @commit, index.commit
46
+ end
47
+
48
+ def test_new
49
+ index = ReaPack::Index.new @dummy_path
50
+
51
+ assert_equal 1, index.version
52
+ assert_nil index.commit
53
+
54
+ assert_equal true, index.modified?
55
+ assert_equal "empty index", index.changelog
56
+
57
+ index.write @dummy_path
58
+ assert_equal true, index.modified?
59
+
60
+ index.write!
61
+ assert_equal false, index.modified?
62
+ end
63
+
64
+ def test_save
65
+ index = ReaPack::Index.new @real_path
66
+
67
+ index.write @dummy_path
68
+ assert_equal File.read(@real_path), File.read(@dummy_path)
69
+ end
70
+
71
+ def test_mkdir
72
+ path = File.expand_path '../dummy_dir/test.xml', __FILE__
73
+ dirname = File.dirname path
74
+
75
+ refute File.exist? dirname
76
+
77
+ index = ReaPack::Index.new path
78
+ index.write!
79
+
80
+ assert File.exist? dirname
81
+ ensure
82
+ FileUtils.rm_r dirname if File.exist? dirname
83
+ end
84
+
85
+ def test_ignore_unknown_type
86
+ index = ReaPack::Index.new @dummy_path
87
+
88
+ index.scan 'src/main.cpp', String.new
89
+ index.write!
90
+
91
+ expected = <<-XML
92
+ <?xml version="1.0" encoding="utf-8"?>
93
+ <index version="1"/>
94
+ XML
95
+
96
+ assert_equal expected, File.read(@dummy_path)
97
+ end
98
+
99
+ def test_new_package
100
+ index = ReaPack::Index.new @dummy_path
101
+ assert_empty index.files
102
+
103
+ index.files = ['Category/Path/Instrument Track.lua']
104
+ index.source_pattern = '$path'
105
+ index.scan index.files.first, <<-IN
106
+ @version 1.0
107
+ @changelog Hello World
108
+ IN
109
+
110
+ assert_equal true, index.modified?
111
+ assert_equal '1 new category, 1 new package, 1 new version', index.changelog
112
+
113
+ index.write!
114
+
115
+ assert_equal false, index.modified?
116
+ assert_empty index.changelog
117
+
118
+ expected = <<-XML
119
+ <?xml version="1.0" encoding="utf-8"?>
120
+ <index version="1">
121
+ <category name="Category/Path">
122
+ <reapack name="Instrument Track.lua" type="script">
123
+ <version name="1.0">
124
+ <changelog><![CDATA[Hello World]]></changelog>
125
+ <source platform="all">Category/Path/Instrument%20Track.lua</source>
126
+ </version>
127
+ </reapack>
128
+ </category>
129
+ </index>
130
+ XML
131
+
132
+ assert_equal expected, File.read(index.path)
133
+ end
134
+
135
+ def test_default_category
136
+ index = ReaPack::Index.new @dummy_path
137
+ assert_empty index.files
138
+
139
+ index.files = ['script.lua', 'Hello/World']
140
+ index.source_pattern = '$path'
141
+ index.scan index.files.first, <<-IN
142
+ @version 1.0
143
+ @provides Hello/World
144
+ IN
145
+
146
+ expected = <<-XML
147
+ <?xml version="1.0" encoding="utf-8"?>
148
+ <index version="1">
149
+ <category name="Other">
150
+ <reapack name="script.lua" type="script">
151
+ <version name="1.0">
152
+ <source platform="all">script.lua</source>
153
+ <source platform="all" file="Hello/World">Hello/World</source>
154
+ </version>
155
+ </reapack>
156
+ </category>
157
+ </index>
158
+ XML
159
+
160
+ index.write!
161
+ assert_equal expected, File.read(index.path)
162
+ end
163
+
164
+ def test_edit_version_amend_off
165
+ index = ReaPack::Index.new @real_path
166
+ assert_equal false, index.amend
167
+ index.source_pattern = 'http://google.com/$path'
168
+
169
+ index.files = ['Category Name/Hello World.lua']
170
+ index.scan index.files.first, <<-IN
171
+ @version 1.0
172
+ @changelog New Changelog!
173
+ IN
174
+
175
+ assert_equal false, index.modified?
176
+ assert_empty index.changelog
177
+ end
178
+
179
+ def test_edit_version_amend_on
180
+ index = ReaPack::Index.new @real_path
181
+ index.amend = true
182
+ assert_equal true, index.amend
183
+
184
+ index.source_pattern = 'http://google.com/$path'
185
+ index.files = ['Category Name/Hello World.lua']
186
+ index.scan index.files.first, <<-IN
187
+ @version 1.0
188
+ @changelog New Changelog!
189
+ IN
190
+
191
+ assert index.modified?, 'index is not modified'
192
+ assert_equal '1 modified package, 1 modified version', index.changelog
193
+
194
+ expected = <<-XML
195
+ <?xml version="1.0" encoding="utf-8"?>
196
+ <index version="1" commit="#{@commit}">
197
+ <category name="Category Name">
198
+ <reapack name="Hello World.lua" type="script">
199
+ <version name="1.0">
200
+ <changelog><![CDATA[New Changelog!]]></changelog>
201
+ <source platform="all">http://google.com/Category%20Name/Hello%20World.lua</source>
202
+ </version>
203
+ </reapack>
204
+ </category>
205
+ </index>
206
+ XML
207
+
208
+ index.write @dummy_path
209
+ assert_equal expected, File.read(@dummy_path)
210
+ end
211
+
212
+ def test_edit_version_amend_unmodified
213
+ index = ReaPack::Index.new @real_path
214
+ index.amend = true
215
+ index.source_pattern = 'https://google.com/$path'
216
+
217
+ index.files = ['Category Name/Hello World.lua']
218
+ index.scan index.files.first, <<-IN
219
+ @version 1.0
220
+ @author cfillion
221
+ @changelog Fixed a division by zero error.
222
+ IN
223
+
224
+ assert_equal false, index.modified?
225
+ assert_empty index.changelog
226
+ end
227
+
228
+ def test_file_unlisted
229
+ index = ReaPack::Index.new @dummy_path
230
+ index.source_pattern = 'http://google.com/$path'
231
+
232
+ error = assert_raises ReaPack::Index::Error do
233
+ index.scan 'unlisted.lua', <<-IN
234
+ @version 1.0
235
+ IN
236
+ end
237
+
238
+ assert_equal 'unlisted.lua: No such file or directory', error.message
239
+
240
+ expected = <<-XML
241
+ <?xml version="1.0" encoding="utf-8"?>
242
+ <index version="1"/>
243
+ XML
244
+
245
+ index.write!
246
+ assert_equal expected, File.read(index.path)
247
+ end
248
+
249
+ def test_source_pattern_unset
250
+ index = ReaPack::Index.new @dummy_path
251
+ index.files = ['script.lua']
252
+
253
+ error = assert_raises ReaPack::Index::Error do
254
+ index.scan index.files.first, <<-IN
255
+ @version 1.0
256
+ IN
257
+ end
258
+
259
+ assert_match /source pattern is unset/i, error.message
260
+ end
261
+
262
+ def test_source_pattern_no_path
263
+ index = ReaPack::Index.new @dummy_path
264
+ index.files = ['script.lua']
265
+
266
+ assert_raises ArgumentError do
267
+ index.source_pattern = 'no path variable here'
268
+ end
269
+ end
270
+
271
+ def test_source_pattern_defaut_branch
272
+ index = ReaPack::Index.new @dummy_path
273
+ index.files = ['Category/script.lua']
274
+ index.source_pattern = '$commit/$path'
275
+
276
+ index.commit = nil
277
+
278
+ index.scan index.files.first, <<-IN
279
+ @version 1.0
280
+ IN
281
+
282
+ expected = <<-XML
283
+ <?xml version="1.0" encoding="utf-8"?>
284
+ <index version="1">
285
+ <category name="Category">
286
+ <reapack name="script.lua" type="script">
287
+ <version name="1.0">
288
+ <source platform="all">master/Category/script.lua</source>
289
+ </version>
290
+ </reapack>
291
+ </category>
292
+ </index>
293
+ XML
294
+
295
+ index.write!
296
+ assert_equal expected, File.read(@dummy_path)
297
+ end
298
+
299
+ def test_source_pattern_commit
300
+ index = ReaPack::Index.new @dummy_path
301
+ index.files = ['Category/script.lua']
302
+ index.source_pattern = '$commit/$path'
303
+
304
+ index.commit = @commit
305
+
306
+ index.scan index.files.first, <<-IN
307
+ @version 1.0
308
+ IN
309
+
310
+ expected = <<-XML
311
+ <?xml version="1.0" encoding="utf-8"?>
312
+ <index version="1" commit="#{@commit}">
313
+ <category name="Category">
314
+ <reapack name="script.lua" type="script">
315
+ <version name="1.0">
316
+ <source platform="all">#{@commit}/Category/script.lua</source>
317
+ </version>
318
+ </reapack>
319
+ </category>
320
+ </index>
321
+ XML
322
+
323
+ index.write!
324
+ assert_equal expected, File.read(@dummy_path)
325
+ end
326
+
327
+ def test_nil_source_pattern
328
+ index = ReaPack::Index.new @dummy_path
329
+
330
+ error = assert_raises ArgumentError do
331
+ index.source_pattern = nil
332
+ end
333
+ end
334
+
335
+ def test_missing_version
336
+ index = ReaPack::Index.new @dummy_path
337
+ index.source_pattern = '$path'
338
+ index.files = ['test.lua']
339
+
340
+ error = assert_raises ReaPack::Index::Error do
341
+ index.scan index.files.first, 'no version tag here'
342
+ end
343
+
344
+ assert_match 'missing tag "version"', error.message
345
+ end
346
+
347
+ def test_changelog_boolean
348
+ index = ReaPack::Index.new @dummy_path
349
+ index.source_pattern = '$path'
350
+ index.files = ['test.lua']
351
+
352
+ error = assert_raises ReaPack::Index::Error do
353
+ index.scan index.files.first, <<-IN
354
+ @version 1.0
355
+ @changelog
356
+ IN
357
+ end
358
+
359
+ assert_match 'invalid value for tag "changelog"', error.message
360
+ end
361
+
362
+ def test_author
363
+ index = ReaPack::Index.new @dummy_path
364
+ index.source_pattern = '$path'
365
+ index.files = ['Category/script.lua']
366
+
367
+ index.scan index.files.first, <<-IN
368
+ @version 1.0
369
+ @author cfillion
370
+ IN
371
+
372
+ expected = <<-XML
373
+ <?xml version="1.0" encoding="utf-8"?>
374
+ <index version="1">
375
+ <category name="Category">
376
+ <reapack name="script.lua" type="script">
377
+ <version name="1.0" author="cfillion">
378
+ <source platform="all">Category/script.lua</source>
379
+ </version>
380
+ </reapack>
381
+ </category>
382
+ </index>
383
+ XML
384
+
385
+ index.write!
386
+ assert_equal expected, File.read(index.path)
387
+ end
388
+
389
+ def test_author_boolean
390
+ index = ReaPack::Index.new @dummy_path
391
+ index.source_pattern = '$path'
392
+ index.files = ['test.lua']
393
+
394
+ error = assert_raises ReaPack::Index::Error do
395
+ index.scan index.files.first, <<-IN
396
+ @version 1.0
397
+ @author
398
+ IN
399
+ end
400
+
401
+ assert_match 'invalid value for tag "author"', error.message
402
+ end
403
+
404
+ def test_author_multiline
405
+ index = ReaPack::Index.new @dummy_path
406
+ index.source_pattern = '$path'
407
+ index.files = ['test.lua']
408
+
409
+ error = assert_raises ReaPack::Index::Error do
410
+ index.scan index.files.first, <<-IN
411
+ @version 1.0
412
+ @author
413
+ hello
414
+ world
415
+ IN
416
+ end
417
+
418
+ assert_equal 'invalid metadata: invalid value for tag "author"', error.message
419
+ end
420
+
421
+ def test_provides
422
+ index = ReaPack::Index.new @dummy_path
423
+ index.source_pattern = '$path'
424
+
425
+ index.files = [
426
+ 'Category/script.lua',
427
+ 'Resources/unicode.dat',
428
+ 'Category/test.png',
429
+ ]
430
+
431
+ index.scan index.files.first, <<-IN
432
+ @version 1.0
433
+ @provides
434
+ ../Resources/unicode.dat
435
+ test.png
436
+ IN
437
+
438
+ expected = <<-XML
439
+ <?xml version="1.0" encoding="utf-8"?>
440
+ <index version="1">
441
+ <category name="Category">
442
+ <reapack name="script.lua" type="script">
443
+ <version name="1.0">
444
+ <source platform="all">Category/script.lua</source>
445
+ <source platform="all" file="../Resources/unicode.dat">Resources/unicode.dat</source>
446
+ <source platform="all" file="test.png">Category/test.png</source>
447
+ </version>
448
+ </reapack>
449
+ </category>
450
+ </index>
451
+ XML
452
+
453
+ index.write!
454
+ assert_equal expected, File.read(@dummy_path)
455
+ end
456
+
457
+ def test_provides_unlisted
458
+ index = ReaPack::Index.new @dummy_path
459
+ index.source_pattern = '$path'
460
+
461
+ index.files = ['Category/script.lua']
462
+
463
+ error = assert_raises ReaPack::Index::Error do
464
+ index.scan index.files.first, <<-IN
465
+ @version 1.0
466
+ @provides
467
+ test.png
468
+ IN
469
+ end
470
+
471
+ assert_equal 'Category/test.png: No such file or directory', error.message
472
+ end
473
+
474
+ def test_provides_duplicate
475
+ index = ReaPack::Index.new @dummy_path
476
+ index.source_pattern = '$path'
477
+
478
+ error = assert_raises ReaPack::Index::Error do
479
+ index.scan 'script.lua', <<-IN
480
+ @version 1.0
481
+ @provides
482
+ test.png
483
+ test.png http://url.com
484
+ IN
485
+ end
486
+
487
+ assert_match 'invalid value for tag "provides": duplicate file (test.png)',
488
+ error.message
489
+ end
490
+
491
+ def test_provides_duplicate_platforms
492
+ index = ReaPack::Index.new @dummy_path
493
+ index.source_pattern = '$path'
494
+ index.files = ['script.lua', 'test.png', 'test.png']
495
+
496
+ index.scan index.files.first, <<-IN
497
+ @version 1.0
498
+ @provides
499
+ [windows] test.png
500
+ [darwin] test.png
501
+ IN
502
+ end
503
+
504
+ def test_invalid_platform
505
+ index = ReaPack::Index.new @dummy_path
506
+ index.source_pattern = '$path'
507
+
508
+ error = assert_raises ReaPack::Index::Error do
509
+ index.scan 'test.lua', <<-IN
510
+ @version 1.0
511
+ @provides
512
+ [hello] test.png
513
+ IN
514
+ end
515
+
516
+ assert_match 'invalid value for tag "provides": invalid platform hello',
517
+ error.message
518
+ end
519
+
520
+ def test_provides_platform
521
+ index = ReaPack::Index.new @dummy_path
522
+ index.source_pattern = '$path'
523
+
524
+ index.files = [
525
+ 'Category/script.lua',
526
+ 'Category/winall.png',
527
+ 'Category/win32bit.png',
528
+ 'Category/win64bit.png',
529
+ 'Category/osxall.png',
530
+ 'Category/osx32bit.png',
531
+ 'Category/osx64bit.png',
532
+ ]
533
+
534
+ index.scan index.files.first, <<-IN
535
+ @version 1.0
536
+ @provides
537
+ [windows] winall.png
538
+ [win32] win32bit.png
539
+ [win64]win64bit.png
540
+ [ darwin ] osxall.png
541
+ [darwin32] osx32bit.png
542
+ [darwin64] osx64bit.png
543
+ IN
544
+
545
+ expected = <<-XML
546
+ <?xml version="1.0" encoding="utf-8"?>
547
+ <index version="1">
548
+ <category name="Category">
549
+ <reapack name="script.lua" type="script">
550
+ <version name="1.0">
551
+ <source platform="all">Category/script.lua</source>
552
+ <source platform="windows" file="winall.png">Category/winall.png</source>
553
+ <source platform="win32" file="win32bit.png">Category/win32bit.png</source>
554
+ <source platform="win64" file="win64bit.png">Category/win64bit.png</source>
555
+ <source platform="darwin" file="osxall.png">Category/osxall.png</source>
556
+ <source platform="darwin32" file="osx32bit.png">Category/osx32bit.png</source>
557
+ <source platform="darwin64" file="osx64bit.png">Category/osx64bit.png</source>
558
+ </version>
559
+ </reapack>
560
+ </category>
561
+ </index>
562
+ XML
563
+
564
+ index.write!
565
+ assert_equal expected, File.read(@dummy_path)
566
+ end
567
+
568
+ def test_main_platform
569
+ index = ReaPack::Index.new @dummy_path
570
+ index.source_pattern = '$path'
571
+
572
+ index.files = [
573
+ 'Category/script.lua',
574
+ ]
575
+
576
+ index.scan index.files.first, <<-IN
577
+ @version 1.0
578
+ @provides
579
+ [darwin] .
580
+ [win64] script.lua
581
+ IN
582
+
583
+ expected = <<-XML
584
+ <?xml version="1.0" encoding="utf-8"?>
585
+ <index version="1">
586
+ <category name="Category">
587
+ <reapack name="script.lua" type="script">
588
+ <version name="1.0">
589
+ <source platform="darwin">Category/script.lua</source>
590
+ <source platform="win64">Category/script.lua</source>
591
+ </version>
592
+ </reapack>
593
+ </category>
594
+ </index>
595
+ XML
596
+
597
+ index.write!
598
+ assert_equal expected, File.read(@dummy_path)
599
+ end
600
+
601
+ def test_source_custom_url
602
+ index = ReaPack::Index.new @dummy_path
603
+
604
+ index.files = [
605
+ 'Category/script.lua',
606
+ ]
607
+
608
+ index.scan index.files.first, <<-IN
609
+ @version 1.0
610
+ @provides
611
+ script.lua http://google.com/download/$commit/$version/$path
612
+ IN
613
+
614
+ expected = <<-XML
615
+ <?xml version="1.0" encoding="utf-8"?>
616
+ <index version="1">
617
+ <category name="Category">
618
+ <reapack name="script.lua" type="script">
619
+ <version name="1.0">
620
+ <source platform="all">http://google.com/download/master/1.0/Category/script.lua</source>
621
+ </version>
622
+ </reapack>
623
+ </category>
624
+ </index>
625
+ XML
626
+
627
+ index.write!
628
+ assert_equal expected, File.read(@dummy_path)
629
+ end
630
+
631
+ def test_remove
632
+ index = ReaPack::Index.new @real_path
633
+
634
+ index.remove 'Category Name/Hello World.lua'
635
+
636
+ assert_equal true, index.modified?
637
+ assert_equal '1 removed package', index.changelog
638
+
639
+ expected = <<-XML
640
+ <?xml version="1.0" encoding="utf-8"?>
641
+ <index version="1" commit="#{@commit}"/>
642
+ XML
643
+
644
+ index.write @dummy_path
645
+ assert_equal expected, File.read(@dummy_path)
646
+ end
647
+
648
+ def test_remove_inexistant
649
+ index = ReaPack::Index.new @real_path
650
+
651
+ index.remove '404.lua'
652
+
653
+ assert_equal false, index.modified?
654
+ assert_empty index.changelog
655
+ end
656
+
657
+ def test_noindex
658
+ index = ReaPack::Index.new @real_path
659
+
660
+ index.scan 'script.lua', '@noindex'
661
+
662
+ assert_equal false, index.modified?
663
+ end
664
+
665
+ def test_noindex_remove
666
+ index = ReaPack::Index.new @real_path
667
+
668
+ index.scan 'Category Name/Hello World.lua', '@noindex'
669
+
670
+ assert_equal true, index.modified?
671
+ assert_equal '1 removed package', index.changelog
672
+
673
+ expected = <<-XML
674
+ <?xml version="1.0" encoding="utf-8"?>
675
+ <index version="1" commit="#{@commit}"/>
676
+ XML
677
+
678
+ index.write @dummy_path
679
+ assert_equal expected, File.read(@dummy_path)
680
+ end
681
+
682
+ def test_version_time
683
+ index = ReaPack::Index.new @dummy_path
684
+ index.source_pattern = '$path'
685
+ index.files = ['Category/script.lua']
686
+
687
+ index.time = Time.new 2016, 2, 11, 20, 16, 40, -5 * 3600
688
+
689
+ index.scan index.files.first, <<-IN
690
+ @version 1.0
691
+ IN
692
+
693
+ expected = <<-XML
694
+ <?xml version="1.0" encoding="utf-8"?>
695
+ <index version="1">
696
+ <category name="Category">
697
+ <reapack name="script.lua" type="script">
698
+ <version name="1.0" time="2016-02-12T01:16:40Z">
699
+ <source platform="all">Category/script.lua</source>
700
+ </version>
701
+ </reapack>
702
+ </category>
703
+ </index>
704
+ XML
705
+
706
+ index.write!
707
+ assert_equal expected, File.read(index.path)
708
+ end
709
+
710
+ def test_add_anonymous_link
711
+ index = ReaPack::Index.new @dummy_path
712
+
713
+ assert_equal 0, index.links(:website).size
714
+ index.eval_link :website, 'http://test.com'
715
+ assert_equal 1, index.links(:website).size
716
+
717
+ assert_equal '1 new website link, empty index', index.changelog
718
+
719
+ index.write!
720
+ end
721
+
722
+ def test_add_named_link
723
+ index = ReaPack::Index.new @dummy_path
724
+
725
+ assert_equal 0, index.links(:website).size
726
+ index.eval_link :website, 'Test=http://test.com/hello=world'
727
+ assert_equal 1, index.links(:website).size
728
+
729
+ assert_equal '1 new website link, empty index', index.changelog
730
+
731
+ index.write!
732
+ expected = <<-XML
733
+ <?xml version="1.0" encoding="utf-8"?>
734
+ <index version="1">
735
+ <metadata>
736
+ <link rel="website" href="http://test.com/hello=world">Test</link>
737
+ </metadata>
738
+ </index>
739
+ XML
740
+
741
+ index.write @dummy_path
742
+ assert_equal expected, File.read(@dummy_path)
743
+ end
744
+
745
+ def test_edit_link
746
+ index = ReaPack::Index.new @dummy_path
747
+ index.eval_link :website, 'Test=http://test.com'
748
+ index.eval_link :website, 'Test=http://test.com'
749
+ assert_equal '1 new website link, empty index', index.changelog
750
+
751
+ index.eval_link :website, 'Test=http://test.com/hello'
752
+ assert_equal '1 new website link, 1 modified website link, empty index',
753
+ index.changelog
754
+ end
755
+
756
+ def test_remove_link_by_name
757
+ index = ReaPack::Index.new @dummy_path
758
+ index.eval_link :website, 'Test=http://test.com'
759
+ index.eval_link :website, '-Test'
760
+ assert_equal '1 new website link, 1 removed website link, empty index', index.changelog
761
+ end
762
+
763
+ def test_remove_link_by_url
764
+ index = ReaPack::Index.new @dummy_path
765
+ index.eval_link :website, 'Test=http://test.com'
766
+ index.eval_link :website, '-http://test.com'
767
+ assert_equal '1 new website link, 1 removed website link, empty index', index.changelog
768
+ end
769
+
770
+ def test_description
771
+ index = ReaPack::Index.new @dummy_path
772
+ index.write!
773
+
774
+ assert_empty index.description
775
+ assert_equal false, index.modified?
776
+
777
+ index.description = 'Hello World'
778
+ refute_empty index.description
779
+ assert_equal true, index.modified?
780
+ assert_equal '1 modified metadata', index.changelog
781
+
782
+ index.write!
783
+
784
+ index.description = 'Hello World'
785
+ assert_equal false, index.modified?
786
+ end
787
+
788
+ def test_extension
789
+ index = ReaPack::Index.new @dummy_path
790
+
791
+ index.files = [
792
+ 'Extensions/reapack.ext',
793
+ ]
794
+
795
+ index.scan index.files.first, <<-IN
796
+ @version 1.0
797
+ @provides
798
+ reaper_reapack.so http://example.com/$path
799
+ IN
800
+
801
+ expected = <<-XML
802
+ <?xml version="1.0" encoding="utf-8"?>
803
+ <index version="1">
804
+ <category name="Extensions">
805
+ <reapack name="reapack.ext" type="extension">
806
+ <version name="1.0">
807
+ <source platform="all" file="reaper_reapack.so">http://example.com/reaper_reapack.so</source>
808
+ </version>
809
+ </reapack>
810
+ </category>
811
+ </index>
812
+ XML
813
+
814
+ index.write!
815
+ assert_equal expected, File.read(@dummy_path)
816
+ end
817
+ end