Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output improvements #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

h0tw1r3
Copy link

@h0tw1r3 h0tw1r3 commented Feb 17, 2024

  • inspect all property value types except String
  • single quote property strings if it doesn't need to be escaped, otherwise inspect
  • use symbols for with keys
  • improve output formatting

Old:

it { is_expected.to contain_class('Apt')
  .with('update_defaults'     => '{"frequency"=>"reluctantly", "loglevel"=>nil, "timeout"=>nil, "tries"=>nil}')
  .with('purge_defaults'      => '{"sources.list"=>false, "sources.list.d"=>false, "preferences"=>false, "preferences.d"=>false, "apt.conf.d"=>false}')
  .with('proxy_defaults'      => '{"ensure"=>nil, "host"=>nil, "port"=>8080, "https"=>false, "https_acng"=>false, "direct"=>false}')
  .with('include_defaults'    => '{"deb"=>true, "src"=>false}')
  .with('provider'            => '/usr/bin/apt-get')
  .with('keyserver'           => 'keyserver.ubuntu.com')
  .with('ppa_options'         => '["-y"]')
  .with('ppa_package'         => 'software-properties-common')
  .with('backports'           => '{"location"=>"http://archive.ubuntu.com/ubuntu", "repos"=>"main universe multiverse restricted"}')
  .with('confs'               => '{}')
  .with('update'              => '{}')
  .with('purge'               => '{}')
  .with('proxy'               => '{}')
  .with('sources'             => '{}')
  .with('keys'                => '{}')
  .with('keyrings'            => '{}')
  .with('ppas'                => '{}')
  .with('pins'                => '{}')
  .with('settings'            => '{}')
  .with('manage_auth_conf'    => 'true')
  .with('auth_conf_entries'   => '[]')
  .with('auth_conf_owner'     => '_apt')
  .with('root'                => '/etc/apt')
  .with('sources_list'        => '/etc/apt/sources.list')
  .with('sources_list_d'      => '/etc/apt/sources.list.d')
  .with('conf_d'              => '/etc/apt/apt.conf.d')
  .with('preferences'         => '/etc/apt/preferences')
  .with('preferences_d'       => '/etc/apt/preferences.d')
  .with('apt_conf_d'          => '/etc/apt/apt.conf.d')
  .with('config_files'        => '{"conf"=>{"path"=>"/etc/apt/apt.conf.d", "ext"=>""}, "pref"=>{"path"=>"/etc/apt/preferences.d", "ext"=>".pref"}, "list"=>{"path"=>"/etc/apt/sources.list.d", "ext"=>".list"}}')
  .with('sources_list_force'  => 'false')
  .with('source_key_defaults' => '{"server"=>"keyserver.ubuntu.com", "options"=>nil, "content"=>nil, "source"=>nil}')
}

it { is_expected.to contain_class('Apt::Update')
}

it { is_expected.to contain_apt__setting('conf-update-stamp')
  .with('priority'      => '15')
  .with('content'       => '// This file is managed by Puppet. DO NOT EDIT.
APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};
')
  .with('ensure'        => 'file')
  .with('notify_update' => 'true')
}

New:

it {
  is_expected.to contain_class('Apt')
    .with(
      update_defaults:     {"frequency"=>"reluctantly", "loglevel"=>nil, "timeout"=>nil, "tries"=>nil},
      purge_defaults:      {"sources.list"=>false, "sources.list.d"=>false, "preferences"=>false, "preferences.d"=>false, "apt.conf.d"=>false},
      proxy_defaults:      {"ensure"=>nil, "host"=>nil, "port"=>8080, "https"=>false, "https_acng"=>false, "direct"=>false},
      include_defaults:    {"deb"=>true, "src"=>false},
      provider:            '/usr/bin/apt-get',
      keyserver:           'keyserver.ubuntu.com',
      ppa_options:         ["-y"],
      ppa_package:         'software-properties-common',
      backports:           {"location"=>"http://archive.ubuntu.com/ubuntu", "repos"=>"main universe multiverse restricted"},
      confs:               {},
      update:              {},
      purge:               {},
      proxy:               {},
      sources:             {},
      keys:                {},
      keyrings:            {},
      ppas:                {},
      pins:                {},
      settings:            {},
      manage_auth_conf:    true,
      auth_conf_entries:   [],
      auth_conf_owner:     '_apt',
      root:                '/etc/apt',
      sources_list:        '/etc/apt/sources.list',
      sources_list_d:      '/etc/apt/sources.list.d',
      conf_d:              '/etc/apt/apt.conf.d',
      preferences:         '/etc/apt/preferences',
      preferences_d:       '/etc/apt/preferences.d',
      apt_conf_d:          '/etc/apt/apt.conf.d',
      config_files:        {"conf"=>{"path"=>"/etc/apt/apt.conf.d", "ext"=>""}, "pref"=>{"path"=>"/etc/apt/preferences.d", "ext"=>".pref"}, "list"=>{"path"=>"/etc/apt/sources.list.d", "ext"=>".list"}},
      sources_list_force:  false,
      source_key_defaults: {"server"=>"keyserver.ubuntu.com", "options"=>nil, "content"=>nil, "source"=>nil},
}

it { is_expected.to contain_class('Apt::Update') }

it {
  is_expected.to contain_apt__setting('conf-update-stamp')
    .with(
      priority:      15,
      content:       "// This file is managed by Puppet. DO NOT EDIT.\nAPT::Update::Post-Invoke-Success {\"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true\";};\n",
      ensure:        'file',
      notify_update: true,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant