Skip to content

Commit

Permalink
Merge pull request #11 from Yuav/add_tests
Browse files Browse the repository at this point in the history
Add basic spec tests
  • Loading branch information
bastelfreak authored Sep 26, 2016
2 parents 6e46722 + efe1954 commit 798424c
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 54 deletions.
5 changes: 5 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
yum: "#{source_dir}"
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ matrix:
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.4.0-preview1
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" CHECK=acceptance BEAKER_debug=true BEAKER_set=docker/centos-5 PUPPET_INSTALL_TYPE=agent PUPPET_INSTALL_VERSION=1.5.1
services: docker
sudo: required
bundler_args: --without development
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" CHECK=acceptance BEAKER_debug=true BEAKER_set=docker/centos-7 PUPPET_INSTALL_TYPE=agent PUPPET_INSTALL_VERSION=1.5.1
services: docker
sudo: required
bundler_args: --without development
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" CHECK=acceptance BEAKER_debug=true BEAKER_set=docker/centos-6 PUPPET_INSTALL_TYPE=agent PUPPET_INSTALL_VERSION=1.5.1
services: docker
sudo: required
bundler_args: --without development
allow_failures:
- rvm: 2.4.0-preview1
notifications:
Expand Down
3 changes: 1 addition & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
$installonly_limit = 5
$keep_kernel_devel = false
}

default: {
fail("Unsupported OS family: ${::osfamily}")
fail("${::operatingsystem} not supported")
}
}
}
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
}
],
"requirements": [
{
"name": "pe",
"version_requirement": "3.3.x"
},
{
"name": "puppet",
"version_requirement": ">= 3.0.0 < 5.0.0"
Expand Down
16 changes: 16 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper_acceptance'

describe 'yum class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'must work idempotently with no errors' do
pp = <<-EOS
class { 'yum': }
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
end
12 changes: 0 additions & 12 deletions spec/acceptance/nodesets/debian-78-x64.yml

This file was deleted.

12 changes: 0 additions & 12 deletions spec/acceptance/nodesets/debian-82-x64.yml

This file was deleted.

16 changes: 16 additions & 0 deletions spec/acceptance/nodesets/docker/centos-5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HOSTS:
centos-5-x64:
default_apply_opts:
order: random
strict_variables:
platform: el-5-x86_64
hypervisor : docker
image: tianon/centos:5.10
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'yum install -y crontabs tar wget which'
- 'sed -i -e "/mingetty/d" /etc/inittab'
CONFIG:
type: aio
log_level: debug
13 changes: 13 additions & 0 deletions spec/acceptance/nodesets/docker/centos-6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
HOSTS:
centos-6-x64:
platform: el-6-x86_64
image: centos:centos6
hypervisor: docker
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'yum install -y wget tar ntpdate rubygems ruby-augeas ruby-devel augeas-devel'
- 'touch /etc/sysconfig/network'
docker_preserve_image: true
CONFIG:
log_level: debug
type: aio
12 changes: 12 additions & 0 deletions spec/acceptance/nodesets/docker/centos-7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HOSTS:
centos-7-x64:
platform: el-7-x86_64
hypervisor: docker
image: centos:7
docker_preserve_image: true
docker_cmd: '["/usr/sbin/init"]'
docker_image_commands:
- 'yum install -y crontabs tar wget'
CONFIG:
type: aio
log_level: debug
12 changes: 0 additions & 12 deletions spec/acceptance/nodesets/ubuntu-server-1204-x64.yml

This file was deleted.

12 changes: 0 additions & 12 deletions spec/acceptance/nodesets/ubuntu-server-1404-x64.yml

This file was deleted.

32 changes: 32 additions & 0 deletions spec/classes/basic_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

describe 'yum' do
context 'supported operating systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end

context 'yum class without any parameters' do
it { is_expected.to compile.with_all_deps }

it { is_expected.to contain_class('yum::params') }
end
end
end
end

context 'unsupported operating system' do
describe 'yum class without any parameters on Solaris/Nexenta' do
let(:facts) do
{
osfamily: 'Solaris',
operatingsystem: 'Nexenta'
}
end

it { expect { is_expected.to contain_package('yum') }.to raise_error(Puppet::Error, %r{Nexenta not supported}) }
end
end
end
20 changes: 20 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'beaker-rspec'

install_puppet_agent_on hosts, {} unless ENV['BEAKER_provision'] == 'no'

RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

# Readable test descriptions
c.formatter = :documentation

# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(source: proj_root, module_name: 'yum')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1]
end
end
end

0 comments on commit 798424c

Please sign in to comment.