try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / spec / type / nova_aggregate_spec.rb
1 # run with: rspec spec/type/nova_aggregate_spec.rb
2
3 require 'spec_helper'
4
5
6 describe Puppet::Type.type(:nova_aggregate) do
7   before :each do
8     @provider_class = described_class.provide(:simple) do
9       mk_resource_methods
10       def create; end
11       def delete; end
12       def exists?; get(:ensure) != :absent; end
13       def flush; end
14       def self.instances; []; end
15     end
16   end
17
18   it "should be able to create an instance" do
19     described_class.new(:name => 'agg0').should_not be_nil
20   end
21
22   it "should be able to create an more complex instance" do
23     described_class.new(:name => 'agg0',
24                         :availability_zone => 'myzone',
25                         :metadata => "a=b, c=d",
26                         :hosts => "host1").should_not be_nil
27   end
28
29   it "should be able to create an more complex instance with multiple hosts" do
30     described_class.new(:name => 'agg0',
31                         :availability_zone => 'myzone',
32                         :metadata => "a=b, c=d",
33                         :hosts => "host1, host2").should_not be_nil
34   end
35
36   it "should be able to create a instance and have the default values" do
37     c = described_class.new(:name => 'agg0')
38     c[:name].should == "agg0"
39     c[:availability_zone].should == nil
40     c[:metadata].should == nil
41     c[:hosts].should == nil
42   end
43
44   it "should return the given values" do
45     c = described_class.new(:name => 'agg0',
46                             :availability_zone => 'myzone',
47                             :metadata => "  a  =  b  , c=  d  ",
48                             :hosts => "  host1, host2    ")
49     c[:name].should == "agg0"
50     c[:availability_zone].should == "myzone"
51     c[:metadata].should == {"a" => "b", "c" => "d"}
52     c[:hosts].should == ["host1" , "host2"]
53   end
54
55   it "should return the given values" do
56     c = described_class.new(:name => 'agg0',
57                             :availability_zone => "",
58                             :metadata => "",
59                             :hosts => "")
60     c[:name].should == "agg0"
61     c[:availability_zone].should == ""
62     c[:metadata].should == {}
63     c[:hosts].should == []
64   end
65
66 end