aboutsummaryrefslogtreecommitdiffstats
path: root/t/rpmdb.t
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2002-05-31 10:21:16 +0000
committerFrancois Pons <fpons@mandriva.com>2002-05-31 10:21:16 +0000
commit548baa81a0a4e3db8120e9d0e33cf75c1bf77a5e (patch)
tree472f9f9ecacbf8996f1ee28a9c70a465d16c8819 /t/rpmdb.t
parent9de7e3110b4c105da73d051e26c239e22b276020 (diff)
downloadperl-URPM-548baa81a0a4e3db8120e9d0e33cf75c1bf77a5e.tar
perl-URPM-548baa81a0a4e3db8120e9d0e33cf75c1bf77a5e.tar.gz
perl-URPM-548baa81a0a4e3db8120e9d0e33cf75c1bf77a5e.tar.bz2
perl-URPM-548baa81a0a4e3db8120e9d0e33cf75c1bf77a5e.tar.xz
perl-URPM-548baa81a0a4e3db8120e9d0e33cf75c1bf77a5e.zip
initial revision.
Diffstat (limited to 't/rpmdb.t')
-rw-r--r--t/rpmdb.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/rpmdb.t b/t/rpmdb.t
new file mode 100644
index 0000000..c6a1040
--- /dev/null
+++ b/t/rpmdb.t
@@ -0,0 +1,39 @@
+
+use strict ;
+use warnings ;
+
+sub ok {
+ my ($no, $ok) = @_ ;
+
+ print "ok $no\n" if $ok ;
+ print "not ok $no\n" unless $ok ;
+ printf "# Failed test at line %d\n", (caller)[2] unless $ok ;
+}
+
+use URPM;
+
+print "1..5\n";
+
+my $db;
+ok(1, $db = URPM::DB::open);
+
+my @all_pkgs_extern = sort { $a cmp $b } split '\n', `rpm -qa`;
+ok(2, @all_pkgs_extern > 0);
+
+my @all_pkgs;
+my $count = $db->traverse(sub {
+ my ($pkg) = @_;
+ my ($name, $version, $release, $arch) = $pkg->fullname;
+ $arch or return;
+ push @all_pkgs, "$name-$version-$release";
+ });
+ok(3, $count == @all_pkgs_extern);
+ok(4, $count == @all_pkgs);
+
+my @all_pkgs_sorted = sort { $a cmp $b } @all_pkgs;
+my $bad_pkgs = 0;
+foreach (0..$#all_pkgs_sorted) {
+ $all_pkgs_sorted[$_] eq $all_pkgs_extern[$_] or ++$bad_pkgs;
+}
+ok(5, $bad_pkgs == 0);
+