Merge branch 'feature/erenfro/kitchen' of Linux-Help/cookbook-yum-rsyslog into develop

This commit is contained in:
psi-jack 2016-12-08 22:39:31 +00:00 committed by Gogs
commit 157e598c44
9 changed files with 123 additions and 1 deletions

25
.kitchen.yml Normal file
View file

@ -0,0 +1,25 @@
---
driver:
name: docker
provisioner:
name: chef_zero
environments_path: test/environments
client_rb:
environment: integration_test_env
platforms:
- name: centos-7.2-chef-12
driver_config:
image: centos:7.2.1511
platform: rhel
require_chef_omnibus: 12.16.42
use_sudo: false
hostname: integration.test.test
suites:
- name: default
data_bags_path: "test/integration/data_bags"
run_list:
- recipe[yum-rsyslog]

7
Gemfile Normal file
View file

@ -0,0 +1,7 @@
source 'https://rubygems.org'
gem 'berkshelf'
gem 'test-kitchen'
gem 'chefspec'
gem 'foodcritic'
gem 'kitchen-docker'

1
chefignore Normal file
View file

@ -0,0 +1 @@
.kitchen

View file

@ -4,7 +4,7 @@ maintainer_email 'psi-jack@linux-help.org'
license 'Apache 2.0'
description 'Installs and configures the Official Rsyslog Yum Repository'
long_description ''
version '0.1.1'
version '0.1.2'
issues_url 'http://gogs.home.ld/Linux-Help/cookbook-yum-rsyslog/issues'
source_url 'http://gogs.home.ld/Linux-Help/cookbook-yum-rsyslog'

10
spec/spec_helper.rb Normal file
View file

@ -0,0 +1,10 @@
require 'chefspec'
require 'chefspec/berkshelf'
RSpec.configure do |config|
config.platform = 'centos'
config.version = '7.2.1511'
end
ChefSpec::Coverage.start!

View file

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'yum-rsyslog::default' do
context 'Creates rsyslog YUM repository and enables it.' do
let(:chef_run) do
ChefSpec::SoloRunner.new do |node|
# Create a new environment (you could also use a different :let block or :before block)
env = Chef::Environment.new
env.name 'unit_test'
# Stub the node to return this environment
allow(node).to receive(:chef_environment).and_return(env.name)
# Stub any calls to Environment.load to return this environment
allow(Chef::Environment).to receive(:load).and_return(env)
# Stubbing out fqdn node attribute
node.automatic['fqdn'] = 'unit.testing.stub'
end.converge(described_recipe)
end
#before(:each) do
#stub_command("rpm -qa zabbix-release-2.4-1.el6.noarch ").and_return(false)
#allow(Chef::EncryptedDataBagItem).to receive(:load).with('odhp_credentials', 'credentials').and_return(
#{
# 'zabbix' => {
# 'users' => {
# 'unit_test_env' => {
# 'postgres' => {
# 'username' => 'postgres_username',
# 'password' => 'postgres_password'
# }
# }
# }
# }
#})
#end
it 'installs the rsyslog repository' do
expect(chef_run).to create_yum_repository('rsyslog')
end
end
end

View file

@ -0,0 +1,16 @@
{
"name": "integration_test_env",
"description": "placeholder for integration testing",
"cookbook_versions": {
},
"json_class": "Chef::Environment",
"chef_type": "environment",
"default_attributes": {
},
"override_attributes": {
}
}

View file

@ -0,0 +1,15 @@
require 'spec_helper'
describe 'yum-rsyslog::default' do
describe yumrepo('rsyslog') do
it { should be_enabled }
end
describe file('/etc/yum.repos.d/rsyslog.repo') do
it { should be_file }
it { should be_mode 644 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end
end

View file

@ -0,0 +1,4 @@
require 'serverspec'
set :backend, :exec