Arepa

 view release on metacpan or  search on metacpan

t/004-repository.t  view on Meta::CPAN

                             components    => 'main',
                             architectures => 'i386',
                             suite         => 'unstable',
                             alsoacceptfor => 'lenny' },
                           { codename      => 'another',
                             components    => 'main',
                             architectures => 'i386',
                             suite         => 'ubuntu',
                             alsoacceptfor => 'lucid lucidlynx' });

my $r2 = Arepa::Repository->new(TEST_REPO_ADD_CONFIG_FILE);
cmp_deeply([ $r2->get_distributions ], \@initial_distro_list,
           "Distribution information should be correct");

# Duplicate codename
ok(! $r2->add_distribution(codename      => 'initial',
                           components    => 'main',
                           architectures => 'i386'),
   "Shouldn't be able to add a duplicate codename");
cmp_deeply([ $r2->get_distributions ], \@initial_distro_list,
           "Distribution information should be correct");

# Duplicate suite
ok(! $r2->add_distribution(codename      => 'new',
                           components    => 'main',
                           architectures => 'i386',
                           suite         => 'ubuntu'),
   "Shouldn't be able to add a duplicate distribution alias");
cmp_deeply([ $r2->get_distributions ], \@initial_distro_list,
           "Distribution information should be correct");

# "Cross duplicates" (a suite shouldn't be already there as codename)
ok(! $r2->add_distribution(codename      => 'new',
                           components    => 'main',
                           architectures => 'i386',
                           suite         => 'another'),
   "Shouldn't be able to add a suite that existed as a codename");
cmp_deeply([ $r2->get_distributions ], \@initial_distro_list,
           "Distribution information should be correct");

# "Cross duplicates" (codename as suite this time)
ok(! $r2->add_distribution(codename      => 'ubuntu',
                           components    => 'main',
                           architectures => 'i386',
                           suite         => 'newone'),
   "Shouldn't be able to add a codename that existed as a suite");
cmp_deeply([ $r2->get_distributions ], \@initial_distro_list,
           "Distribution information should be correct");

# Add a distribution (repeating AlsoAcceptFor is ok though)
my %new_distro = (codename      => 'new',
                  components    => 'main',
                  architectures => 'i386',
                  suite         => 'lucidlynx');
ok($r2->add_distribution(%new_distro),
   "Should be able to add a new distribution");
cmp_deeply([ $r2->get_distributions ],
           [ @initial_distro_list, \%new_distro ],
           "Distribution information should be correct");

# Check that after adding a distribution, the repository is updated
ok(-d "$tmp_repo/dists/new",
   "After adding distribution 'new', '$tmp_repo/dists/new' should exist");

rmtree($tmp_repo);


# Insert a source package with more than one architecture --------------------
ok($r->insert_source_package('t/upload_queue/multiarch_1.0-1.dsc',
                             'lenny-opera'),
   "Inserting a multiarch source package should succeed");
ok($r->{package_db}->get_source_package_id('multiarch', '1.0-1'),
   "After inserting the multiarch package, it should be in the package db");
my %multiarch_props = $r->get_source_package_information('multiarch',
                                                         'lenny-opera');
ok(scalar %multiarch_props,
   "Source package w/ multiple architectures should be present");

ok($r->insert_source_package('t/upload_queue/multiarch2_1.0-1.dsc',
                             'lenny-opera'),
   "Inserting a multiarch source package should succeed (2)");
ok($r->{package_db}->get_source_package_id('multiarch2', '1.0-1'),
   "After inserting the multiarch package, it should be in the package db (2)");
my %multiarch2_props = $r->get_source_package_information('multiarch2',
                                                          'lenny-opera');
ok(scalar %multiarch2_props,
   "Source package w/ multiple architectures should be present (2)");



( run in 1.164 second using v1.01-cache-2.11-cpan-5a3173703d6 )