Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/portupgrade
Path: blob/master/tests/test_portinfo.rb
102 views
1
#!/usr/bin/env ruby
2
#
3
$:.push("..")
4
5
require 'test/unit'
6
7
require 'pkgtools/ports'
8
9
class TestPortInfo < Test::Unit::TestCase
10
SAMPLE1 = "ruby-perl-0.2.7|/usr/ports/lang/ruby-perl|/usr/local|A Ruby extension module to use the functions of Perl from Ruby|/usr/ports/lang/ruby-perl/pkg-descr|[email protected]|lang ruby perl5|ruby-1.6.2.2001.02.05|ruby-1.6.2.2001.02.05|http://www.yoshidam.net/Ruby.html#perl\n"
11
SAMPLE2 = "ruby-byaccr-0.0_1|/usr/ports/devel/ruby-byaccr|/usr/local|Parser generator for ruby based on 'Berkeley Yacc' and 'Berkeley Yacc for Java'|/usr/ports/devel/ruby-byaccr/pkg-descr|[email protected]|devel ruby|||\n"
12
13
def test_s_new
14
assert_raises(ArgumentError) { PortInfo.new(nil) }
15
assert_raises(ArgumentError) { PortInfo.new('baa') }
16
17
portinfo = PortInfo.new(SAMPLE1)
18
assert_equal(['ruby-perl', '0.2.7',
19
'lang/ruby-perl', 'lang/ruby-perl/pkg-descr',
20
'/usr/local', '[email protected]',
21
'A Ruby extension module to use the functions of Perl from Ruby',
22
['lang', 'ruby', 'perl5'],
23
['ruby-1.6.2.2001.02.05'], ['ruby-1.6.2.2001.02.05'],
24
'http://www.yoshidam.net/Ruby.html#perl'],
25
[portinfo.pkgname.name, portinfo.pkgname.version.to_s,
26
portinfo.origin, portinfo.descr_file,
27
portinfo.prefix, portinfo.maintainer,
28
portinfo.comment,
29
portinfo.categories,
30
portinfo.build_depends, portinfo.run_depends,
31
portinfo.www])
32
33
portinfo = PortInfo.new(SAMPLE2);
34
assert_equal(['ruby-byaccr', '0.0_1',
35
'devel/ruby-byaccr', 'devel/ruby-byaccr/pkg-descr',
36
'/usr/local', '[email protected]',
37
'Parser generator for ruby based on \'Berkeley Yacc\' and \'Berkeley Yacc for Java\'',
38
['devel', 'ruby'],
39
[], [],
40
nil],
41
[portinfo.pkgname.name, portinfo.pkgname.version.to_s,
42
portinfo.origin, portinfo.descr_file,
43
portinfo.prefix, portinfo.maintainer,
44
portinfo.comment,
45
portinfo.categories,
46
portinfo.build_depends, portinfo.run_depends,
47
portinfo.www])
48
end
49
50
def test_to_s
51
assert_equal(SAMPLE1, PortInfo.new(SAMPLE1).to_s)
52
assert_equal(SAMPLE2, PortInfo.new(SAMPLE2).to_s)
53
end
54
end
55
56