From 3a0373f896e3b440e4f97445161fa149cbd0c7e9 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 27 Feb 2024 14:08:08 +0100 Subject: [PATCH] Add acceptance test for aptly::mirror --- .rubocop_todo.yml | 7 +------ spec/acceptance/basic_spec.rb | 35 ++++++++++++++++++++++++++++++++++ spec/system/mirror_spec.rb | 36 ----------------------------------- 3 files changed, 36 insertions(+), 42 deletions(-) delete mode 100644 spec/system/mirror_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6b53e1b..0d6aee0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-02-27 12:38:44 UTC using RuboCop version 1.50.2. +# on 2024-02-27 15:10:28 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -10,8 +10,3 @@ RSpec/RepeatedExampleGroupBody: Exclude: - 'spec/defines/mirror_spec.rb' - -# Offense count: 1 -Style/MixinUsage: - Exclude: - - 'spec/spec_helper_system.rb' diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 0fd195b..fd733a7 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -13,4 +13,39 @@ end end end + + context 'mirror' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-PUPPET + include apt + include aptly + $package = $facts['os']['name'] ? { + 'Debian' => 'debian-archive-keyring', + 'Ubuntu' => 'ubuntu-keyring', + } + package { $package: + ensure => 'installed', + } + exec { 'import_keyring': + command => "/usr/bin/gpg --no-default-keyring --keyring /usr/share/keyrings/${facts['os']['name'].downcase}-archive-keyring.gpg --export | /usr/bin/gpg --no-default-keyring --keyring trustedkeys.gpg --import", + creates => '/root/.gnupg/trustedkeys.gpg', + } + ~> exec { 'puppetkey': + command => '/usr/bin/wget -O - https://apt.puppet.com/keyring.gpg | gpg --no-default-keyring --keyring trustedkeys.gpg --import', + refreshonly => true, + } + -> aptly::mirror { 'puppetlabs': + location => 'https://apt.puppet.com/', + key => 'D6811ED3ADEEB8441AF5AA8F4528B6CD9E61EF26', + release => 'bookworm', + repos => ['puppet8'], + } + PUPPET + end + end + describe command('aptly mirror show puppetlabs') do + its(:stdout) { is_expected.to match %r{Archive Root URL: https://apt.puppet.com/} } + end + end end diff --git a/spec/system/mirror_spec.rb b/spec/system/mirror_spec.rb deleted file mode 100644 index 6857ce0..0000000 --- a/spec/system/mirror_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper_system' - -describe 'mirror tests' do - it 'class should work without errors and be idempotent' do - pp = <<-EOS - class { 'apt': } - class { 'aptly': } - - aptly::mirror { 'puppetlabs': - location => 'http://apt.puppetlabs.com/', - key => '4BD6EC30', - release => 'precise', - repos => ['main', 'dependencies'], - } - EOS - - puppet_apply(pp) do |r| - r.exit_code.should eq 2 - r.refresh - r.exit_code.should be_zero - end - end - - it 'has installed aptly' do - shell 'aptly mirror show puppetlabs' do |r| - r.stdout.should =~ %r{^Name: puppetlabs -Archive Root URL: http://apt\.puppetlabs\.com/ -Distribution: precise -Components: main, dependencies$} - r.stderr.should be_empty - r.exit_code.should be_zero - end - end -end