From 6ee7c1328363fa988f9620266d55ba015c19c9bc Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Sun, 29 Dec 2013 21:25:45 +0100 Subject: [PATCH] Add init unit test (WIP) Signed-off-by: Emilien Macchi --- .fixtures.yml | 1 + manifests/init.pp | 10 ++-- spec/classes/privatecloud_init_spec.rb | 81 ++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index f08ab1fb..84ac94a3 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -23,6 +23,7 @@ fixtures: repo: 'git://github.com/puppetlabs/puppetlabs-rabbitmq' ref: 'origin/2.x' 'memcached': 'git://github.com/saz/puppet-memcached' + 'ntp': 'git://github.com/enovance/puppetlabs-ntp.git' 'sysctl': 'git://github.com/duritong/puppet-sysctl.git' 'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile' 'vswitch': 'git://github.com/stackforge/puppet-vswitch' diff --git a/manifests/init.pp b/manifests/init.pp index f39a2483..972fc781 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -44,11 +44,11 @@ This node is under the control of Puppet ${::puppetversion}. # DNS $datacenter = 'ci' - class{ 'resolver': - dcinfo => { ci => $os_params::dns_ips, }, - domainname => $os_params::site_domain, - searchpath => $os_params::site_domain, - } + class{ 'resolver': + dcinfo => { ci => $os_params::dns_ips, }, + domainname => $os_params::site_domain, + searchpath => $os_params::site_domain, + } # NTP class { 'ntp': } diff --git a/spec/classes/privatecloud_init_spec.rb b/spec/classes/privatecloud_init_spec.rb index e69de29b..dc8a0592 100644 --- a/spec/classes/privatecloud_init_spec.rb +++ b/spec/classes/privatecloud_init_spec.rb @@ -0,0 +1,81 @@ +# +# Copyright (C) 2013 eNovance SAS +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for privatecloud +# + +require 'spec_helper' + +describe 'privatecloud' do + + shared_examples_for 'private cloud node' do + + let :pre_condition do + ' + include concat::setup + ' + end + + let :file_defaults do + { + :mode => '0644' + } + end + it {should contain_file('/etc/motd').with( + {:ensure => 'file'}.merge(file_defaults) + )} + + it 'should build motd file with correct message' do + verify_contents(subject, '/etc/motd', + [ + "############################################################################", + "# eNovance IT Operations #", + "############################################################################", + "# #", + "# *** RESTRICTED ACCESS *** #", + "# Only the authorized users may access this system. #", + "# Any attempted unauthorized access or any action affecting the computer #", + "# system of eNovance is punishable under articles 323-1 to 323-7 of #", + "# French criminal law. #", + "# #", + "############################################################################", + "This node is under the control of Puppet ${::puppetversion}." + ] + ) + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian', + :concat_basedir => '/var/lib/puppet/concat', + :puppetversion => '3.3' } + end + +# it_configures 'private cloud node' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat', + :concat_basedir => '/var/lib/puppet/concat', + :puppetversion => '3.3' } + end + +# it_configures 'private cloud node' + end + +end