mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
add mysql unit tests
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
58fa9bc6c7
commit
ddbaebae46
4 changed files with 28 additions and 1 deletions
|
@ -12,6 +12,7 @@ SimpleCov.start do
|
|||
end
|
||||
|
||||
require 'vulcano/backend'
|
||||
require 'vulcano/resource'
|
||||
|
||||
# loads a resource class and instantiates the class with the given arguments
|
||||
def loadResource (resource, *args)
|
||||
|
@ -40,7 +41,9 @@ def loadResource (resource, *args)
|
|||
'/etc/security/limits.conf' => mockfile.('limits.conf'),
|
||||
'/etc/inetd.conf' => mockfile.('inetd.conf'),
|
||||
'/etc/group' => mockfile.('group'),
|
||||
'/etc/audit/auditd.conf' => mockfile.('auditd.conf')
|
||||
'/etc/audit/auditd.conf' => mockfile.('auditd.conf'),
|
||||
'/etc/mysql/my.cnf' => mockfile.('mysql.conf'),
|
||||
'/etc/mysql/mysql2.conf' => mockfile.('mysql2.conf')
|
||||
}
|
||||
|
||||
# create all mock commands
|
||||
|
|
8
test/unit/mock/files/mysql.conf
Normal file
8
test/unit/mock/files/mysql.conf
Normal file
|
@ -0,0 +1,8 @@
|
|||
# a comment...
|
||||
[client]
|
||||
port = 3306
|
||||
|
||||
[mysqld]
|
||||
user = mysql
|
||||
|
||||
!include mysql2.conf
|
2
test/unit/mock/files/mysql2.conf
Normal file
2
test/unit/mock/files/mysql2.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
[mysqld]
|
||||
key_buffer_size=16M
|
14
test/unit/resource_mysql_conf_test.rb
Normal file
14
test/unit/resource_mysql_conf_test.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# encoding: utf-8
|
||||
require 'helper'
|
||||
|
||||
describe 'Vulcano::Resources::MysqlConf' do
|
||||
describe 'mysql_conf' do
|
||||
let(:resource) { loadResource('mysql_conf', '/etc/mysql/my.cnf') }
|
||||
|
||||
it 'verify mysql.conf config parsing' do
|
||||
_(resource.client['port']).must_equal '3306'
|
||||
_(resource.mysqld['user']).must_equal 'mysql'
|
||||
_(resource.mysqld['key_buffer_size']).must_equal '16M'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue