ruby-rpm 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'rpm'
3
+
4
+ class RPM_File_Tests < Test::Unit::TestCase
5
+ def test_link_to
6
+ f = RPM::File.new("path", "md5sum", nil, 42, 1,
7
+ "owner", "group", 43, 0777, 44, 45)
8
+ assert_equal(nil, f.link_to)
9
+ f = RPM::File.new("path", "md5sum", "link_to", 42, 1,
10
+ "owner", "group", 43, 0777, 44, 45)
11
+ assert_equal("link_to", f.link_to)
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'rpm'
3
+
4
+ class RPM_RPM_Tests < Test::Unit::TestCase
5
+ def test_macro_read
6
+ assert_equal( RPM['_usr'], '/usr' )
7
+ end # def test_macro_read
8
+
9
+ def test_macro_write
10
+ RPM['hoge'] = 'hoge'
11
+ assert_equal( RPM['hoge'], 'hoge' )
12
+ end # def test_macro_write
13
+ end # class RPM_RPM_Tests < Test::Unit::TestCase
@@ -0,0 +1,31 @@
1
+ require 'test/unit'
2
+ require 'rpm'
3
+
4
+ class RPM_Source_Tests < Test::Unit::TestCase
5
+ def setup
6
+ @a = RPM::Source.new( 'http://example.com/hoge/hoge.tar.bz2', 0 )
7
+ @b = RPM::Source.new( 'http://example.com/fuga/fuga.tar.gz', 1, true )
8
+ end
9
+
10
+ def test_fullname
11
+ assert_equal( 'http://example.com/hoge/hoge.tar.bz2', @a.fullname )
12
+ end
13
+
14
+ def test_to_s
15
+ assert_equal( 'http://example.com/hoge/hoge.tar.bz2', @a.to_s )
16
+ end
17
+
18
+ def test_filename
19
+ assert_equal( 'hoge.tar.bz2', @a.filename )
20
+ end
21
+
22
+ def test_num
23
+ assert_equal( 0, @a.num )
24
+ assert_equal( 1, @b.num )
25
+ end
26
+
27
+ def test_no?
28
+ assert_equal(false, @a.no?)
29
+ assert( @b.no?)
30
+ end
31
+ end
@@ -0,0 +1,169 @@
1
+ raise NotImplementedError, "not implemented yet..."
2
+
3
+ require 'test/unit'
4
+ require 'tmpdir'
5
+ require 'rpm'
6
+
7
+ class TC_TransactionSet < Test::Unit::TestCase
8
+ SPEC_A = <<END_SPEC_A
9
+ Summary: Spec A for Testing Ruby/RPM.
10
+ Name: spec-a
11
+ Version: 1.0
12
+ Release: 1m
13
+ Group: Documentation
14
+ License: GPL
15
+
16
+ BuildArchitectures: noarch
17
+
18
+ %description
19
+ Spec A for Testing Ruby/RPM.
20
+
21
+ %files
22
+ %defattr(-, root, root)
23
+
24
+ %changelog
25
+ * Sun May 23 2004 Kenta MURATA <muraken2@nifty.com>
26
+ - (1.0-1m)
27
+ - initial release.
28
+ END_SPEC_A
29
+
30
+ SPEC_C = <<END_SPEC_C
31
+ Summary: Spec C for Testing Ruby/RPM.
32
+ Name: spec-c
33
+ Version: 1.0
34
+ Release: 1m
35
+ Group: Documentation
36
+ License: GPL
37
+
38
+ BuildArchitectures: noarch
39
+
40
+ Requires: spec-b
41
+
42
+ %description
43
+ Spec C for Testing Ruby/RPM.
44
+
45
+ %files
46
+ %defattr(-, root, root)
47
+
48
+ %changelog
49
+ * Sun May 23 2004 Kenta MURATA <muraken2@nifty.com>
50
+ - (1.0-1m)
51
+ - initial release.
52
+ END_SPEC_C
53
+
54
+ def init_rpmmacros(path)
55
+ File.open(path, "w") do |io|
56
+ io.puts("%_topdir #{@rpm_dir}")
57
+ end
58
+ end
59
+
60
+ def init_rpmrc(path)
61
+ File.open(path, "w") do |io|
62
+ io.puts("macrofiles: #{@rpm_dir}/macros")
63
+ end
64
+ end
65
+
66
+ def build_spec(rpmrc, path)
67
+ log = `rpmbuild --rcfile=/usr/lib/rpm/rpmrc:#{rpmrc} -ba #{path}`
68
+ if $?.exitstatus != 0 then
69
+ raise RuntimeError, log
70
+ end
71
+ end
72
+
73
+ def setup
74
+ require 'fileutils'
75
+ @work_dir = Dir.tmpdir + "/.ruby-rpm-test"
76
+
77
+ @rpm_dir = "#{@work_dir}/rpm"
78
+ %W(SPECS SRPMS SOURCES RPMS/#{RPM['_arch']} RPMS/noarch BUILD SRPMS).each do |dir|
79
+ FileUtils.mkdir_p("#{@rpm_dir}/#{dir}")
80
+ end
81
+
82
+ @root_dir = "#{@work_dir}/root"
83
+ FileUtils.mkdir_p("#{@root_dir}#{RPM['_dbpath']}")
84
+
85
+ ## build spec file for testing
86
+ init_rpmrc("#{@rpm_dir}/rpmrc") unless File.file?("#{@rpm_dir}/rpmrc")
87
+ init_rpmmacros("#{@rpm_dir}/macros") unless File.file?("#{@rpm_dir}/macros")
88
+ self.class.constants.grep(/^SPEC_/).each do |name|
89
+ filename = name.downcase + ".spec"
90
+ next if File.file?("#{@rpm_dir}/RPMS/noarch/#{filename}")
91
+ File.open("#{@rpm_dir}/SPECS/#{filename}", "w") do |io|
92
+ io.print(self.class.const_get(name))
93
+ end
94
+ build_spec("#{@rpm_dir}/rpmrc", "#{@rpm_dir}/SPECS/#{filename}")
95
+ end
96
+
97
+ @ts = RPM::TransactionSet.new(@root_dir)
98
+ end
99
+
100
+ def teardown
101
+ @ts.empty!
102
+ @ts.close_db
103
+
104
+ # If available following code, rpmbuild process is forked by for
105
+ # each test_* methods...
106
+ ## FileUtils.rm_rf(@work_dir)
107
+ end
108
+
109
+ def test_00_init_db
110
+ assert_nothing_raised { @ts.init_db }
111
+ assert(File.exist?("#{@root_dir}/#{RPM[:_dbpath]}/Packages"))
112
+ end
113
+
114
+ def test_rebuild_db
115
+ assert_nothing_raised { @ts.rebuild_db }
116
+ end
117
+
118
+ def test_verify_db
119
+ assert_nothing_raised { @ts.verify_db }
120
+ end
121
+
122
+ def test_add_install
123
+ n = @ts.element_count
124
+ @ts.add_install() # XXX
125
+ assert_equal(n + 1, @ts.element_count)
126
+ end
127
+
128
+ def test_add_upgrade
129
+ n = @ts.element_count
130
+ @ts.add_upgrade() # XXX
131
+ assert_equal(n + 1, @ts.element_count)
132
+ end
133
+
134
+ def test_add_available
135
+ n = @ts.element_count
136
+ @ts.add_available() # XXX
137
+ assert_equal(n + 1, @ts.element_count)
138
+ end
139
+
140
+ def test_add_erase
141
+ n = @ts.element_count
142
+ @ts.add_erase() # XXX
143
+ assert_equal(n + 1, @ts.element_count)
144
+ end
145
+
146
+ def test_check
147
+ # not implemented yet
148
+ end
149
+
150
+ def test_order
151
+ # not implemented yet
152
+ end
153
+
154
+ def test_set_flags
155
+ # not implemented yet
156
+ end
157
+
158
+ def test_run
159
+ # not implemented yet
160
+ end
161
+ end
162
+
163
+ #--
164
+ # Local Variables:
165
+ # mode: ruby
166
+ # ruby-indent-level: 2
167
+ # indent-tabs-mode: nil
168
+ # End:
169
+ #++
@@ -0,0 +1,51 @@
1
+ require 'test/unit'
2
+ require 'rpm'
3
+
4
+ class RPM_Version_Tests < Test::Unit::TestCase
5
+ def setup
6
+ @a = RPM::Version.new( '1.0.0-0.1m' )
7
+ @b = RPM::Version.new( '0.9.0-1m' )
8
+ @c = RPM::Version.new( '1.0.0-0.11m' )
9
+ @d = RPM::Version.new( '0.9.0-1m', 1)
10
+ end
11
+
12
+ def test_version_compare
13
+ assert( @a > @b )
14
+ assert( @a < @c )
15
+ assert( @a < @d )
16
+ end
17
+
18
+ def test_version_newer?
19
+ assert( @a.newer?(@b) )
20
+ assert( @c.newer?(@a) )
21
+ assert( @d.newer?(@a) )
22
+ end
23
+
24
+ def test_version_older?
25
+ assert( @b.older?(@a) )
26
+ assert( @a.older?(@c) )
27
+ assert( @a.older?(@d) )
28
+ end
29
+
30
+ def test_vre
31
+ assert_equal( '0.9.0', @d.v )
32
+ assert_equal( '1m', @d.r )
33
+ assert_equal( 1, @d.e )
34
+ end
35
+
36
+ def test_to_s
37
+ assert_equal( '0.9.0-1m', @b.to_s )
38
+ assert_equal( '0.9.0-1m', @d.to_s )
39
+ end
40
+
41
+ def test_to_vre
42
+ assert_equal( '0.9.0-1m', @b.to_vre )
43
+ assert_equal( '1:0.9.0-1m', @d.to_vre )
44
+ end
45
+
46
+ def test_inspect
47
+ v = RPM::Version.new("1", "2", 3)
48
+ assert_equal(3, v.e)
49
+ assert_equal('#<RPM::Version v="1", r="2", e=3>', v.inspect)
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.2
3
+ specification_version: 1
4
+ name: ruby-rpm
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.2.2
7
+ date: 2007-03-21 00:00:00 -07:00
8
+ summary: Ruby bindings for RPM
9
+ require_paths:
10
+ - lib
11
+ email: ruby-rpm-devel@rubyforge.org
12
+ homepage: http://rubyforge.org/projects/ruby-rpm/
13
+ rubyforge_project:
14
+ description: Bindings for accessing RPM packages and databases from Ruby.
15
+ autorequire: rpm
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.1
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors: []
30
+
31
+ files:
32
+ - Rakefile
33
+ - ChangeLog
34
+ - COPYING
35
+ - README
36
+ - NEWS
37
+ - install.rb
38
+ - doc/refm.rd.ja
39
+ - lib/rpm.rb
40
+ - ext/rpm/dependency.c
41
+ - ext/rpm/rpm.c
42
+ - ext/rpm/file.c
43
+ - ext/rpm/private.h
44
+ - ext/rpm/source.c
45
+ - ext/rpm/ruby-rpm.h
46
+ - ext/rpm/db.c
47
+ - ext/rpm/rpm40_compat.c
48
+ - ext/rpm/version.c
49
+ - ext/rpm/rpm40_compat.h
50
+ - ext/rpm/spec.c
51
+ - ext/rpm/package.c
52
+ - ext/rpm/MANIFEST
53
+ - ext/rpm/extconf.rb
54
+ - tests/test_dependency.rb
55
+ - tests/test_rpm.rb
56
+ - tests/test_file.rb
57
+ - tests/test_source.rb
58
+ - tests/test_db.rb
59
+ - tests/test_version.rb
60
+ - tests/test_ts.rb
61
+ - tests/runner.rb
62
+ - spec/fedora
63
+ - spec/fedora/ruby-rpm.spec
64
+ test_files:
65
+ - tests/runner.rb
66
+ rdoc_options: []
67
+
68
+ extra_rdoc_files: []
69
+
70
+ executables: []
71
+
72
+ extensions:
73
+ - ext/rpm/extconf.rb
74
+ requirements: []
75
+
76
+ dependencies: []
77
+