Skip to content

Commit

Permalink
added minitests. New minor version
Browse files Browse the repository at this point in the history
  • Loading branch information
silviabotros committed Jun 27, 2014
1 parent e28dbf8 commit 7c3b8c4
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ driver:
- ['forwarded_port', {guest: 3000, host: 3000, auto_correct: true}]

provisioner:
name: chef_solo
name: chef_zero

platforms:
- name: ubuntu-12.04
Expand All @@ -17,4 +17,5 @@ suites:
- name: default
run_list:
- recipe[orchestrator::default]
- recipe[minitest-handler]
attributes:
1 change: 1 addition & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source "https://api.berkshelf.com"

metadata
cookbook 'minitest-handler', :git => 'https://github.com/btm/minitest-handler-cookbook.git'
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.2.0
Added minitests

# 1.1.1
Chefspec passes and 100% coverage

# 1.1.0
Added Chefspec tests

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ gem 'thor-foodcritic'
gem 'test-kitchen'
gem 'kitchen-vagrant'
gem "chefspec"
gem 'minitest-chef-handler'
37 changes: 37 additions & 0 deletions files/default/tests/minitests/default_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'minitest/spec'
require 'chef/mixin/shell_out'
#
# Cookbook Name:: orchestrator
# Spec:: default
#

describe_recipe 'orchestrator::default' do
include Chef::Mixin::ShellOut
include Minitest::Chef::Assertions
include Minitest::Chef::Context
include Minitest::Chef::Resources

describe "runs orchestrator" do
it 'is running mysql' do
service("mysql").must_be_running
end
it 'has an orchestrator db' do
assert_sh('mysql -e "show databases" | grep orchestrator')
end
it 'has an orchestrator user' do
assert_sh('mysql -e "select user from mysql.user" | grep orchestrator')
end
it 'installs orchestrator' do
package('orchestrator').must_be_installed
end
it 'creates the cfg file' do
file('/etc/orchestrator.conf.json').must_exist
end
it 'removes the packaged cfg file' do
file('/usr/local/orchestrator/conf/orchestrator.conf.json').wont_exist
end
it 'has a process named orchestrator running' do
assert_sh('ps aux | grep orchestrator | grep -v grep')
end
end
end
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'All rights reserved'
description 'Installs/Configures chef-orchestrator'
long_description 'Installs/Configures chef-orchestrator'
version '1.1.0'
version '1.2.0'

depends 'yum'
depends 'database'
Expand Down
12 changes: 4 additions & 8 deletions spec/recipes/_database_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@
expect(chef_run).to enable_service('mysql')
expect(chef_run).to start_service('mysql')
end
it 'doesnt make orchestrator db if it finds it' do
stub_command("mysql -e 'show databases' | grep orchestrator").and_return(true)
expect(chef_run).to_not create_database('orchestrator')
end
it 'makes orchestrator if it is not found' do
it 'makes the orchestrator db when needed' do
stub_command("mysql -e 'show databases' | grep orchestrator").and_return(false)
expect(chef_run).to run_execute('create database orchestrator')
expect(chef_run).to create_mysql_database('orchestrator')
end
it 'created orchestrator user' do
it 'creates orchestrator user' do
stub_command("mysql -e 'select user from mysql.users' | grep orchestrator").and_return(false)
expect(chef_run).to grant_database_user('orchestrator')
expect(chef_run).to grant_mysql_database_user('orchestrator')
end
it 'sets the root pass' do
stub_command("mysql -u root -pfakepass")
Expand Down

0 comments on commit 7c3b8c4

Please sign in to comment.