2015-09-14 13:15:32 +00:00
|
|
|
# encoding utf-8
|
|
|
|
|
|
|
|
require 'helper'
|
|
|
|
require 'vulcano/resource'
|
|
|
|
|
2015-09-21 10:31:14 +00:00
|
|
|
describe 'Vulcano::Resources::Service' do
|
2015-09-14 13:15:32 +00:00
|
|
|
|
2015-09-22 16:33:05 +00:00
|
|
|
# windows
|
2015-09-23 14:30:48 +00:00
|
|
|
it 'verify service parsing' do
|
|
|
|
resource = MockLoader.new(:windows).load_resource('service', 'dhcp')
|
|
|
|
srv = { name: 'dhcp', description: 'DHCP Client', installed: true, running: true, enabled: true, type: 'windows' }
|
|
|
|
_(resource.info).must_equal srv
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.running?).must_equal true
|
|
|
|
end
|
2015-09-23 20:32:31 +00:00
|
|
|
|
|
|
|
# # ubuntu 14.04 with upstart
|
|
|
|
it 'verify ubuntu package parsing' do
|
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource('service', 'ssh')
|
|
|
|
srv = { name: 'ssh', description: '', installed: true, running: true, enabled: true, type: 'upstart' }
|
|
|
|
_(resource.info).must_equal srv
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.running?).must_equal true
|
|
|
|
end
|
2015-09-25 10:48:21 +00:00
|
|
|
|
|
|
|
# centos 7 with systemd
|
|
|
|
it 'verify centos package parsing' do
|
|
|
|
resource = MockLoader.new(:centos7).load_resource('service', 'sshd')
|
|
|
|
srv = { name: 'sshd.service', description: 'OpenSSH server daemon', installed: true, running: true, enabled: true, type: 'systemd' }
|
|
|
|
_(resource.info).must_equal srv
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.running?).must_equal true
|
|
|
|
end
|
2015-09-24 21:32:46 +00:00
|
|
|
|
2015-09-24 21:37:31 +00:00
|
|
|
# arch linux with systemd
|
|
|
|
it 'verify arch linux package parsing' do
|
|
|
|
resource = MockLoader.new(:arch).load_resource('service', 'sshd')
|
|
|
|
srv = { name: 'sshd.service', description: 'OpenSSH server daemon', installed: true, running: true, enabled: true, type: 'systemd' }
|
|
|
|
_(resource.info).must_equal srv
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.running?).must_equal true
|
|
|
|
end
|
|
|
|
|
2015-09-24 21:32:46 +00:00
|
|
|
# debian 8 with systemd
|
|
|
|
it 'verify arch linux package parsing' do
|
|
|
|
resource = MockLoader.new(:debian7).load_resource('service', 'sshd')
|
|
|
|
srv = { name: 'sshd.service', description: 'OpenSSH server daemon', installed: true, running: true, enabled: true, type: 'systemd' }
|
|
|
|
_(resource.info).must_equal srv
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.running?).must_equal true
|
|
|
|
end
|
|
|
|
|
2015-09-25 10:51:12 +00:00
|
|
|
# macos test
|
|
|
|
it 'verify arch linux package parsing' do
|
|
|
|
resource = MockLoader.new(:osx104).load_resource('service', 'ssh')
|
|
|
|
srv = { name: 'org.openbsd.ssh-agent', description: nil, installed: true, running: true, enabled: true, type: 'darwin'}
|
|
|
|
_(resource.info).must_equal srv
|
|
|
|
_(resource.installed?).must_equal true
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.running?).must_equal true
|
|
|
|
end
|
|
|
|
|
2015-09-23 14:32:51 +00:00
|
|
|
# unknown OS
|
|
|
|
it 'verify package handling on unsupported os' do
|
|
|
|
resource = MockLoader.new(:undefined).load_resource('service', 'dhcp')
|
|
|
|
_(resource.installed?).must_equal false
|
|
|
|
_(resource.info).must_equal nil
|
|
|
|
end
|
2015-09-14 13:15:32 +00:00
|
|
|
end
|