diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2010-11-11 13:47:43 -0800 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2010-11-11 13:51:45 -0800 |
| commit | b0acb02b568598ec8dba41aa856f74658b2033dd (patch) | |
| tree | 6b85dd2b572f296cbf23db803c279c1f2160c16c /spec/unit | |
| parent | 2b772f761e151c3c2be41e1688e9af9a22d73dd0 (diff) | |
(#3747) Add specs for upstart provider
Paired-With: Matt Robinson
Diffstat (limited to 'spec/unit')
| -rw-r--r-- | spec/unit/provider/service/upstart.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/unit/provider/service/upstart.rb b/spec/unit/provider/service/upstart.rb new file mode 100644 index 000000000..439fd2c79 --- /dev/null +++ b/spec/unit/provider/service/upstart.rb @@ -0,0 +1,50 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +provider_class = Puppet::Type.type(:service).provider(:upstart) + +describe provider_class do + describe "#instances" do + it "should be able to find all instances" do + processes = ["rc stop/waiting", "ssh start/running, process 712"] + provider_class.stubs(:execpipe).yields(processes) + provider_class.instances.map {|provider| provider.name}.should =~ ["rc","ssh"] + end + + it "should attach the interface name for network interfaces" do + processes = ["network-interface (eth0)"] + provider_class.stubs(:execpipe).yields(processes) + provider_class.instances.first.name.should == "network-interface INTERFACE=eth0" + end + end + + describe "#status" do + it "should allow the user to override the status command" do + resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart, :status => "/bin/foo") + provider = provider_class.new(resource) + + Process::Status.any_instance.stubs(:exitstatus).returns(0) + provider.expects(:ucommand) + provider.status.should == :running + end + + it "should use the default status command if none is specified" do + resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart) + provider = provider_class.new(resource) + + provider.expects(:status_exec).with(["foo"]).returns("foo start/running, process 1000") + Process::Status.any_instance.stubs(:exitstatus).returns(0) + provider.status.should == :running + end + + it "should properly handle services with 'start' in their name" do + resource = Puppet::Type.type(:service).new(:name => "foostartbar", :provider => :upstart) + provider = provider_class.new(resource) + + provider.expects(:status_exec).with(["foostartbar"]).returns("foostartbar stop/waiting") + Process::Status.any_instance.stubs(:exitstatus).returns(0) + provider.status.should == :stopped + end + end +end |
