File: zone_spec.rb

package info (click to toggle)
puppet 2.6.2-5%2Bsqueeze10
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 13,728 kB
  • ctags: 8,726
  • sloc: ruby: 110,196; sh: 937; lisp: 263; xml: 122; sql: 103; makefile: 90; python: 84
file content (60 lines) | stat: -rwxr-xr-x 2,156 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
#!/usr/bin/env ruby

Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }

zone = Puppet::Type.type(:zone)

describe zone do
  before do
    zone = Puppet::Type.type(:zone)
    provider = stub 'provider'
    provider.stubs(:name).returns(:solaris)
    zone.stubs(:defaultprovider).returns(provider)
    resource = stub 'resource', :resource => nil, :provider => provider, :line => nil, :file => nil
  end

  parameters = [:create_args, :install_args, :sysidcfg, :path, :realhostname]

  parameters.each do |parameter|
    it "should have a #{parameter} parameter" do
      zone.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
    end
  end

  properties = [:ip, :iptype, :autoboot, :pool, :shares, :inherit]

  properties.each do |property|
    it "should have a #{property} property" do
      zone.attrclass(property).ancestors.should be_include(Puppet::Property)
    end
  end

  it "should be invalid when :path is missing" do
    lambda { zone.new(:name => "dummy") }.should raise_error
  end

  it "should be invalid when :ip is missing a \":\" and iptype is :shared" do
    lambda { zone.new(:name => "dummy", :ip => "if") }.should raise_error
  end

  it "should be invalid when :ip has a \":\" and iptype is :exclusive" do
    lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4", :iptype => :exclusive) }.should raise_error
  end

  it "should be invalid when :ip has two \":\" and iptype is :exclusive" do
    lambda { zone.new(:name => "dummy", :ip => "if:1.2.3.4:2.3.4.5", :iptype => :exclusive) }.should raise_error
  end

  it "should be valid when :iptype is :shared and using interface and ip" do
    zone.new(:name => "dummy", :path => "/dummy", :ip => "if:1.2.3.4")
  end

  it "should be valid when :iptype is :shared and using interface, ip and default route" do
    zone.new(:name => "dummy", :path => "/dummy", :ip => "if:1.2.3.4:2.3.4.5")
  end

  it "should be valid when :iptype is :exclusive and using interface" do
    zone.new(:name => "dummy", :path => "/dummy", :ip => "if", :iptype => :exclusive)
  end

end