apt-pkg 0.0.4 → 0.5.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.
- checksums.yaml +5 -5
- data/History.md +51 -2
- data/LICENSE +1 -1
- data/README.md +35 -22
- data/ext/apt_pkg/apt-pkg.cpp +148 -88
- data/ext/apt_pkg/apt-pkg.h +3 -1
- data/ext/apt_pkg/configuration.cpp +94 -86
- data/ext/apt_pkg/extconf.rb +2 -5
- data/ext/apt_pkg/pkgcache.cpp +379 -38
- data/ext/apt_pkg/pkgcache.h +1 -0
- data/lib/debian/apt_pkg.rb +4 -0
- data/lib/debian/apt_pkg/gem_version.rb +9 -0
- data/lib/debian/apt_pkg/package.rb +47 -0
- data/test/apt_pkg_cache_not_init_integration.rb +24 -0
- data/test/apt_pkg_configuration_test.rb +35 -31
- data/test/apt_pkg_test.rb +67 -47
- data/test/debian/apt_pkg/package_test.rb +56 -0
- data/test/debian/apt_pkg/pkg_cache_test.rb +114 -0
- data/test/test_helper.rb +1 -1
- metadata +15 -12
- data/test/apt_pkg_cache_test.rb +0 -40
data/ext/apt_pkg/pkgcache.h
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Debian::AptPkg::Package file
|
3
|
+
module Debian
|
4
|
+
# AptPkg base module
|
5
|
+
module AptPkg
|
6
|
+
# Debian::AptPkg::Package class
|
7
|
+
# Representation of a package in a cache
|
8
|
+
class Package
|
9
|
+
attr_accessor :id, :name, :full_name, :arch, :essential, :important,
|
10
|
+
:current_version
|
11
|
+
|
12
|
+
# Initialize the Package class
|
13
|
+
# @example
|
14
|
+
# new(id, name, full_name, arch, essential, important, current_version)
|
15
|
+
# @param [Integer] The numeric ID of the package
|
16
|
+
# @param [String] The name of the package
|
17
|
+
# @param [String] Get the full name of the package, including the
|
18
|
+
# architecture
|
19
|
+
# @param [String] The architecture of the package
|
20
|
+
# @param [Boolean] Boolean value determining whether the package is
|
21
|
+
# essential
|
22
|
+
# @param [Boolean] Boolean value determining whether the package has the
|
23
|
+
# 'important' flag set
|
24
|
+
# ('Important: yes' in the Packages file)
|
25
|
+
# @param [Version,NilClass] The version of the package currently installed
|
26
|
+
# or `nil`
|
27
|
+
# @return [Package] Package instance
|
28
|
+
def initialize(id, name, full_name, arch, essential, important, current_version)
|
29
|
+
@id = id
|
30
|
+
@name = name
|
31
|
+
@full_name = full_name
|
32
|
+
@arch = arch
|
33
|
+
@essential = essential
|
34
|
+
@important = important
|
35
|
+
@current_version = current_version
|
36
|
+
end
|
37
|
+
|
38
|
+
# Return `true` if the package is installed
|
39
|
+
# @return [Boolean]
|
40
|
+
def is_installed
|
41
|
+
return false unless current_version
|
42
|
+
|
43
|
+
true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
describe Debian::AptPkg::PkgCache do
|
5
|
+
describe 'not init' do
|
6
|
+
describe '.update' do
|
7
|
+
it 'can be called' do
|
8
|
+
_(lambda do
|
9
|
+
Debian::AptPkg::PkgCache.update
|
10
|
+
end).must_raise Debian::AptPkg::InitError
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
%i(package version depends package_file ver_file provides group).each do |m|
|
15
|
+
describe ".#{m}_count" do
|
16
|
+
it 'can be called' do
|
17
|
+
_(lambda do
|
18
|
+
Debian::AptPkg::PkgCache.public_send("#{m}_count")
|
19
|
+
end).must_raise Debian::AptPkg::InitError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,74 +1,78 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
3
|
describe Debian::AptPkg::Configuration do
|
4
|
+
before :all do
|
5
|
+
Debian::AptPkg.init
|
6
|
+
end
|
7
|
+
|
4
8
|
it 'architectures return an array' do
|
5
9
|
arches = Debian::AptPkg::Configuration.architectures
|
6
|
-
arches.must_be_instance_of Array
|
7
|
-
arches.wont_be_empty
|
10
|
+
_(arches).must_be_instance_of Array
|
11
|
+
_(arches).wont_be_empty
|
8
12
|
end
|
9
13
|
|
10
14
|
it 'languages return an array' do
|
11
15
|
all_langs = Debian::AptPkg::Configuration.languages
|
12
|
-
all_langs.must_be_instance_of Array
|
13
|
-
all_langs.wont_be_empty
|
16
|
+
_(all_langs).must_be_instance_of Array
|
17
|
+
_(all_langs).wont_be_empty
|
14
18
|
|
15
19
|
langs = Debian::AptPkg::Configuration.languages(false)
|
16
|
-
langs.must_be_instance_of Array
|
20
|
+
_(langs).must_be_instance_of Array
|
17
21
|
end
|
18
22
|
|
19
23
|
it 'check_architecture' do
|
20
|
-
Debian::AptPkg::Configuration.check_architecture('all').must_equal true
|
24
|
+
_(Debian::AptPkg::Configuration.check_architecture('all')).must_equal true
|
21
25
|
|
22
26
|
arches = Debian::AptPkg::Configuration.architectures
|
23
27
|
c = Debian::AptPkg::Configuration.check_architecture(arches.first)
|
24
|
-
c.must_equal true
|
28
|
+
_(c).must_equal true
|
25
29
|
|
26
30
|
# http://buildd.debian-ports.org/status/fetch.php?pkg=ruby2.1&arch=m68k&ver=2.1.2-2&stamp=1400604298
|
27
|
-
Debian::AptPkg::Configuration.check_architecture('m68k').must_equal false
|
31
|
+
_(Debian::AptPkg::Configuration.check_architecture('m68k')).must_equal false
|
28
32
|
end
|
29
33
|
|
30
34
|
it 'check_language' do
|
31
|
-
lambda
|
35
|
+
_(lambda do
|
32
36
|
Debian::AptPkg::Configuration.check_language
|
33
|
-
|
37
|
+
end).must_raise ArgumentError
|
34
38
|
|
35
39
|
langs = Debian::AptPkg::Configuration.languages
|
36
|
-
Debian::AptPkg::Configuration.check_language(langs.first).must_equal true
|
40
|
+
_(Debian::AptPkg::Configuration.check_language(langs.first)).must_equal true
|
37
41
|
|
38
42
|
c = Debian::AptPkg::Configuration.check_language('gallifreyan')
|
39
|
-
c.must_equal false
|
43
|
+
_(c).must_equal false
|
40
44
|
end
|
41
45
|
|
42
46
|
it 'compressors return an array' do
|
43
47
|
cmps = Debian::AptPkg::Configuration.compressors
|
44
|
-
cmps.must_be_instance_of Array
|
45
|
-
cmps.wont_be_empty
|
46
|
-
cmps.must_include 'gz'
|
48
|
+
_(cmps).must_be_instance_of Array
|
49
|
+
_(cmps).wont_be_empty
|
50
|
+
_(cmps).must_include 'gz'
|
47
51
|
end
|
48
52
|
|
49
53
|
it 'find configuration value' do
|
50
|
-
lambda
|
54
|
+
_(lambda do
|
51
55
|
Debian::AptPkg::Configuration.config_find
|
52
|
-
|
56
|
+
end).must_raise ArgumentError
|
53
57
|
|
54
|
-
Debian::AptPkg::Configuration.config_find('Dir::Etc::main')
|
55
|
-
must_equal
|
56
|
-
Debian::AptPkg::Configuration.config_find('Dir::Etc::netrc')
|
57
|
-
must_equal
|
58
|
-
Debian::AptPkg::Configuration.config_find('Dir::Etc::parts')
|
59
|
-
must_equal
|
60
|
-
Debian::AptPkg::Configuration.config_find('Spk', 'DebianUser')
|
61
|
-
must_equal
|
58
|
+
_(Debian::AptPkg::Configuration.config_find('Dir::Etc::main'))
|
59
|
+
.must_equal 'apt.conf'
|
60
|
+
_(Debian::AptPkg::Configuration.config_find('Dir::Etc::netrc'))
|
61
|
+
.must_equal 'auth.conf'
|
62
|
+
_(Debian::AptPkg::Configuration.config_find('Dir::Etc::parts'))
|
63
|
+
.must_equal 'apt.conf.d'
|
64
|
+
_(Debian::AptPkg::Configuration.config_find('Spk', 'DebianUser'))
|
65
|
+
.must_equal 'DebianUser'
|
62
66
|
end
|
63
67
|
|
64
68
|
it 'find file' do
|
65
|
-
lambda
|
69
|
+
_(lambda do
|
66
70
|
Debian::AptPkg::Configuration.config_find_file
|
67
|
-
|
71
|
+
end).must_raise ArgumentError
|
68
72
|
|
69
|
-
Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main')
|
70
|
-
must_equal
|
71
|
-
Debian::AptPkg::Configuration.config_find_file('Dir::Etc::netrc')
|
72
|
-
must_equal
|
73
|
+
_(Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main'))
|
74
|
+
.must_equal '/etc/apt/apt.conf'
|
75
|
+
_(Debian::AptPkg::Configuration.config_find_file('Dir::Etc::netrc'))
|
76
|
+
.must_equal '/etc/apt/auth.conf'
|
73
77
|
end
|
74
78
|
end
|
data/test/apt_pkg_test.rb
CHANGED
@@ -1,114 +1,134 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
3
|
describe Debian::AptPkg do
|
4
|
+
it 'gem has a version number' do
|
5
|
+
refute_nil Debian::AptPkg::VERSION
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'apt has a version number' do
|
9
|
+
refute_nil Debian::AptPkg::APT_VERSION
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'libapt-pkg has a version number' do
|
13
|
+
refute_nil Debian::AptPkg::LIBAPT_PKG_VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.init' do
|
17
|
+
it 'returns a bool' do
|
18
|
+
_(Debian::AptPkg.init).must_equal true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
4
22
|
describe '.cmp_version' do
|
5
|
-
it '
|
6
|
-
Debian::AptPkg.cmp_version('1.1', '1.0').must_be :>, 0
|
7
|
-
Debian::AptPkg.cmp_version('1.0', '1.0').must_be :==, 0
|
8
|
-
Debian::AptPkg.cmp_version('1.0', '1.1').must_be :<, 0
|
23
|
+
it 'compare version' do
|
24
|
+
_(Debian::AptPkg.cmp_version('1.1', '1.0')).must_be :>, 0
|
25
|
+
_(Debian::AptPkg.cmp_version('1.0', '1.0')).must_be :==, 0
|
26
|
+
_(Debian::AptPkg.cmp_version('1.0', '1.1')).must_be :<, 0
|
9
27
|
end
|
10
28
|
end
|
11
29
|
|
12
30
|
describe '.check_dep' do
|
13
31
|
describe 'LessEq' do
|
14
|
-
it '
|
15
|
-
Debian::AptPkg.check_dep('1', '<=', '2').must_equal true
|
16
|
-
Debian::AptPkg.check_dep('2', '<=', '1').must_equal false
|
17
|
-
Debian::AptPkg.check_dep('1', '<=', '1').must_equal true
|
32
|
+
it 'compare Debian version' do
|
33
|
+
_(Debian::AptPkg.check_dep('1', '<=', '2')).must_equal true
|
34
|
+
_(Debian::AptPkg.check_dep('2', '<=', '1')).must_equal false
|
35
|
+
_(Debian::AptPkg.check_dep('1', '<=', '1')).must_equal true
|
18
36
|
end
|
19
37
|
end
|
20
38
|
|
21
39
|
describe 'GreaterEq' do
|
22
|
-
it '
|
23
|
-
Debian::AptPkg.check_dep('1', '>=', '2').must_equal false
|
24
|
-
Debian::AptPkg.check_dep('2', '>=', '1').must_equal true
|
25
|
-
Debian::AptPkg.check_dep('1', '>=', '1').must_equal true
|
40
|
+
it 'compare Debian version' do
|
41
|
+
_(Debian::AptPkg.check_dep('1', '>=', '2')).must_equal false
|
42
|
+
_(Debian::AptPkg.check_dep('2', '>=', '1')).must_equal true
|
43
|
+
_(Debian::AptPkg.check_dep('1', '>=', '1')).must_equal true
|
26
44
|
end
|
27
45
|
end
|
28
46
|
|
29
47
|
describe 'Less' do
|
30
|
-
it '
|
31
|
-
Debian::AptPkg.check_dep('1', '<', '2').must_equal true
|
32
|
-
Debian::AptPkg.check_dep('2', '<', '1').must_equal false
|
33
|
-
Debian::AptPkg.check_dep('1', '<', '1').must_equal false
|
48
|
+
it 'compare Debian version' do
|
49
|
+
_(Debian::AptPkg.check_dep('1', '<', '2')).must_equal true
|
50
|
+
_(Debian::AptPkg.check_dep('2', '<', '1')).must_equal false
|
51
|
+
_(Debian::AptPkg.check_dep('1', '<', '1')).must_equal false
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
37
55
|
describe 'Greater' do
|
38
|
-
it '
|
39
|
-
Debian::AptPkg.check_dep('1', '>', '2').must_equal false
|
40
|
-
Debian::AptPkg.check_dep('2', '>', '1').must_equal true
|
41
|
-
Debian::AptPkg.check_dep('1', '>', '1').must_equal false
|
56
|
+
it 'compare Debian version' do
|
57
|
+
_(Debian::AptPkg.check_dep('1', '>', '2')).must_equal false
|
58
|
+
_(Debian::AptPkg.check_dep('2', '>', '1')).must_equal true
|
59
|
+
_(Debian::AptPkg.check_dep('1', '>', '1')).must_equal false
|
42
60
|
end
|
43
61
|
end
|
44
62
|
|
45
63
|
describe 'Equals' do
|
46
|
-
it '
|
47
|
-
Debian::AptPkg.check_dep('1', '=', '2').must_equal false
|
48
|
-
Debian::AptPkg.check_dep('2', '=', '1').must_equal false
|
49
|
-
Debian::AptPkg.check_dep('1', '=', '1').must_equal true
|
64
|
+
it 'compare Debian version' do
|
65
|
+
_(Debian::AptPkg.check_dep('1', '=', '2')).must_equal false
|
66
|
+
_(Debian::AptPkg.check_dep('2', '=', '1')).must_equal false
|
67
|
+
_(Debian::AptPkg.check_dep('1', '=', '1')).must_equal true
|
50
68
|
end
|
51
69
|
end
|
52
70
|
|
53
71
|
describe 'NotEquals' do
|
54
|
-
it '
|
55
|
-
Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2')
|
56
|
-
must_equal true
|
57
|
-
Debian::AptPkg.check_dep('2', Debian::AptPkg::NOT_EQUALS, '1')
|
58
|
-
must_equal true
|
59
|
-
Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '1')
|
60
|
-
must_equal false
|
72
|
+
it 'compare Debian version' do
|
73
|
+
_(Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2'))
|
74
|
+
.must_equal true
|
75
|
+
_(Debian::AptPkg.check_dep('2', Debian::AptPkg::NOT_EQUALS, '1'))
|
76
|
+
.must_equal true
|
77
|
+
_(Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '1'))
|
78
|
+
.must_equal false
|
61
79
|
end
|
62
80
|
end
|
63
81
|
|
64
82
|
describe 'Errors' do
|
65
|
-
it '
|
66
|
-
lambda
|
83
|
+
it 'raise argument error with bad comparison' do
|
84
|
+
_(lambda do
|
67
85
|
Debian::AptPkg.check_dep('1', 'bad', '2')
|
68
|
-
|
86
|
+
end).must_raise ArgumentError
|
69
87
|
end
|
70
88
|
end
|
71
89
|
end
|
72
90
|
|
73
91
|
describe '.uri_to_filename' do
|
74
|
-
it '
|
75
|
-
Debian::AptPkg.uri_to_filename('http://debian.org/index.html')
|
76
|
-
must_equal 'debian.org_index.html'
|
92
|
+
it 'return a filename which can be used to store the file' do
|
93
|
+
_(Debian::AptPkg.uri_to_filename('http://debian.org/index.html'))
|
94
|
+
.must_equal 'debian.org_index.html'
|
77
95
|
end
|
78
96
|
end
|
79
97
|
|
80
98
|
describe '.upstream_version' do
|
81
99
|
it 'Return the upstream version for the Debian package version' do
|
82
|
-
Debian::AptPkg.upstream_version('3.4.15-1+b1').must_equal '3.4.15'
|
100
|
+
_(Debian::AptPkg.upstream_version('3.4.15-1+b1')).must_equal '3.4.15'
|
83
101
|
end
|
84
102
|
end
|
85
103
|
|
86
104
|
describe '.time_to_str' do
|
87
105
|
it 'Format a given duration in human-readable manner' do
|
88
|
-
Debian::AptPkg.time_to_str(3601).must_equal '1h 0min 1s'
|
106
|
+
_(Debian::AptPkg.time_to_str(3601)).must_equal '1h 0min 1s'
|
89
107
|
end
|
90
108
|
end
|
91
109
|
|
92
110
|
describe '.size_to_str' do
|
93
111
|
it 'Return a string describing the size in a human-readable manner' do
|
94
|
-
Debian::AptPkg.size_to_str(
|
112
|
+
_(Debian::AptPkg.size_to_str(10_000)).must_equal '10.0 k'
|
95
113
|
end
|
96
114
|
end
|
97
115
|
|
98
116
|
describe '.string_to_bool' do
|
99
117
|
it 'Parse the string input and return a boolean' do
|
100
|
-
Debian::AptPkg.string_to_bool('yes').must_equal true
|
101
|
-
Debian::AptPkg.string_to_bool('no').must_equal false
|
102
|
-
Debian::AptPkg.string_to_bool('no-recognized').must_equal false
|
118
|
+
_(Debian::AptPkg.string_to_bool('yes')).must_equal true
|
119
|
+
_(Debian::AptPkg.string_to_bool('no')).must_equal false
|
120
|
+
_(Debian::AptPkg.string_to_bool('no-recognized')).must_equal false
|
103
121
|
end
|
104
122
|
end
|
105
123
|
|
106
124
|
describe '.check_domain_list' do
|
107
125
|
it 'See if the host name given by host is one of the domains given' do
|
108
|
-
Debian::AptPkg.check_domain_list(
|
109
|
-
|
110
|
-
|
111
|
-
|
126
|
+
_(Debian::AptPkg.check_domain_list('alioth.debian.org',
|
127
|
+
'debian.net,debian.org'))
|
128
|
+
.must_equal true
|
129
|
+
_(Debian::AptPkg.check_domain_list('git.debian.org',
|
130
|
+
'spkdev.net'))
|
131
|
+
.must_equal false
|
112
132
|
end
|
113
133
|
end
|
114
134
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../../test_helper'
|
3
|
+
|
4
|
+
describe Debian::AptPkg::Package do
|
5
|
+
let(:id) { 42 }
|
6
|
+
let(:pkg_name) { "ed" }
|
7
|
+
let(:full_name) { "ed:i386" }
|
8
|
+
let(:arch) { "i386" }
|
9
|
+
let(:essential) { false }
|
10
|
+
let(:important) { false }
|
11
|
+
let(:current_version) { nil }
|
12
|
+
|
13
|
+
describe '.new' do
|
14
|
+
describe 'with correct number of arguments' do
|
15
|
+
it 'can initialize a Package class' do
|
16
|
+
Debian::AptPkg::Package.new(id, pkg_name, full_name, arch,
|
17
|
+
essential, important, current_version)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'with wrong number of arguments' do
|
22
|
+
it 'cannot initialize a Package class' do
|
23
|
+
_(lambda do
|
24
|
+
Debian::AptPkg::Package.new(id, pkg_name, full_name, arch,
|
25
|
+
essential, important)
|
26
|
+
end).must_raise ArgumentError
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#is_installed' do
|
32
|
+
subject do
|
33
|
+
Debian::AptPkg::Package.new(id, pkg_name, full_name, arch,
|
34
|
+
essential, important,
|
35
|
+
current_version).is_installed
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'when current_version is present' do
|
39
|
+
let(:current_version) do
|
40
|
+
Debian::AptPkg::Version.new("ed", "1", "editors", "i386", 0, 0, 0, 0, 4)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns true' do
|
44
|
+
_(subject).must_equal true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'when current_version is not present' do
|
49
|
+
let(:current_version) { nil }
|
50
|
+
|
51
|
+
it 'returns false' do
|
52
|
+
_(subject).must_equal false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../../test_helper'
|
3
|
+
|
4
|
+
describe Debian::AptPkg::PkgCache do
|
5
|
+
before :all do
|
6
|
+
Debian::AptPkg.init
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '.update' do
|
10
|
+
it 'can be called' do
|
11
|
+
Debian::AptPkg::PkgCache.update
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.gen_caches' do
|
16
|
+
it 'return boolean' do
|
17
|
+
if Process.uid == 0
|
18
|
+
_(Debian::AptPkg::PkgCache.gen_caches).must_equal true
|
19
|
+
else
|
20
|
+
_(Debian::AptPkg::PkgCache.gen_caches).must_equal false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.is_multi_arch' do
|
26
|
+
it 'can be called' do
|
27
|
+
Debian::AptPkg::PkgCache.is_multi_arch
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.packages' do
|
32
|
+
it 'returns an array of Package' do
|
33
|
+
packages = Debian::AptPkg::PkgCache.packages
|
34
|
+
_(packages).must_be_kind_of Array
|
35
|
+
_(packages.first).must_be_kind_of Debian::AptPkg::Package
|
36
|
+
libapt = packages.find { |pkg| pkg.name == 'libapt-pkg-dev' }
|
37
|
+
_(libapt.id).must_be_kind_of Numeric
|
38
|
+
_(libapt.name).must_equal 'libapt-pkg-dev'
|
39
|
+
_(libapt.full_name).must_match(/libapt-pkg-dev:(\w)/)
|
40
|
+
_(libapt.arch).must_match(/(\w)/)
|
41
|
+
_([true, false]).must_include libapt.essential
|
42
|
+
_([true, false]).must_include libapt.important
|
43
|
+
_(libapt.current_version).must_be_kind_of Debian::AptPkg::Version
|
44
|
+
_(libapt.current_version.parent_package_name).must_equal libapt.name
|
45
|
+
_(libapt.current_version.version_string).must_be_kind_of String
|
46
|
+
_(libapt.current_version.section).must_equal 'libdevel'
|
47
|
+
_(libapt.current_version.arch).must_equal libapt.arch
|
48
|
+
_(libapt.current_version.size).must_be_kind_of Numeric
|
49
|
+
_(libapt.current_version.installed_size).must_be_kind_of Numeric
|
50
|
+
_(libapt.current_version.hash).must_be_kind_of Numeric
|
51
|
+
_(libapt.current_version.id).must_be_kind_of Numeric
|
52
|
+
_(libapt.current_version.priority).must_be_kind_of Numeric
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.pkg_names' do
|
57
|
+
it 'is deprecated' do
|
58
|
+
out, err = capture_io do
|
59
|
+
Debian::AptPkg::PkgCache.pkg_names('libapt-pkg-dev')
|
60
|
+
end
|
61
|
+
_(out).must_equal ''
|
62
|
+
regexp = /warning:\sDebian::AptPkg::PkgCache\.pkg_names\sis\sdeprecated;\s
|
63
|
+
use\sDebian::AptPkg::PkgCache\.packages\sinstead/x
|
64
|
+
_(err).must_match(regexp)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'no argument' do
|
68
|
+
_(lambda do
|
69
|
+
capture_io do
|
70
|
+
Debian::AptPkg::PkgCache.pkg_names
|
71
|
+
end
|
72
|
+
end).must_raise ArgumentError
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'nil argument' do
|
76
|
+
_(lambda do
|
77
|
+
capture_io do
|
78
|
+
Debian::AptPkg::PkgCache.pkg_names(nil)
|
79
|
+
end
|
80
|
+
end).must_raise ArgumentError
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'blank argument' do
|
84
|
+
_(lambda do
|
85
|
+
capture_io do
|
86
|
+
Debian::AptPkg::PkgCache.pkg_names('')
|
87
|
+
end
|
88
|
+
end).must_raise ArgumentError
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'be filtered' do
|
92
|
+
capture_io do
|
93
|
+
search = Debian::AptPkg::PkgCache.pkg_names('vim')
|
94
|
+
# CI specific cache can not be present
|
95
|
+
unless search.nil? || search.empty?
|
96
|
+
_(search).must_include 'vim'
|
97
|
+
_(search).must_include 'vim-nox'
|
98
|
+
_(search).must_include 'vim-gtk'
|
99
|
+
_(search).wont_include 'emacs'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
%i(package version depends package_file ver_file provides group).each do |m|
|
106
|
+
describe ".#{m}_count" do
|
107
|
+
it 'return an int' do
|
108
|
+
if Process.uid == 0
|
109
|
+
_(Debian::AptPkg::PkgCache.public_send("#{m}_count")).must_be :>=, 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|