summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider/zone/solaris_spec.rb
blob: 4a1d032729a32ae29763bbceeea896168442ca07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env ruby

require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')

provider_class = Puppet::Type.type(:zone).provider(:solaris)

describe provider_class do
  before do
    @resource = stub("resource", :name => "mypool")
    @resource.stubs(:[]).returns "shouldvalue"
    @provider = provider_class.new(@resource)
  end

  describe "when calling configure" do
    it "should add the create args to the create str" do
      @resource.stubs(:properties).returns([])
      @resource.stubs(:[]).with(:create_args).returns("create_args")
      @provider.expects(:setconfig).with("create -b create_args\nset zonepath=shouldvalue\ncommit\n")
      @provider.configure
    end
  end

  describe "when installing" do
    it "should call zoneadm" do
      @provider.expects(:zoneadm)
      @provider.install
    end

    describe "when cloning" do
      before { @resource.stubs(:[]).with(:clone).returns(:clone_argument) }

      it "sohuld clone with the resource's clone attribute" do
        @provider.expects(:zoneadm).with(:clone, :clone_argument)
        @provider.install
      end
    end

    describe "when not cloning" do
      before { @resource.stubs(:[]).with(:clone).returns(nil)}

      it "should just install if there are no install args" do
        @resource.stubs(:[]).with(:install_args).returns(nil)
        @provider.expects(:zoneadm).with(:install)
        @provider.install
      end

      it "should add the install args to the command if they exist" do
        @resource.stubs(:[]).with(:install_args).returns("install args")
        @provider.expects(:zoneadm).with(:install, ["install", "args"])
        @provider.install
      end
    end
  end

end