File: nova_aggregate_spec.rb

package info (click to toggle)
puppet-module-nova 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,100 kB
  • sloc: ruby: 11,433; python: 38; sh: 10; makefile: 10
file content (102 lines) | stat: -rw-r--r-- 3,939 bytes parent folder | download | duplicates (5)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# run with: rspec spec/type/nova_aggregate_spec.rb

require 'spec_helper'


describe Puppet::Type.type(:nova_aggregate) do
  before :each do
    @provider_class = described_class.provide(:simple) do
      mk_resource_methods
      def create; end
      def delete; end
      def exists?; get(:ensure) != :absent; end
      def flush; end
      def self.instances; []; end
    end
  end

  it "should be able to create an instance" do
    expect(described_class.new(:name => 'agg0')).not_to be_nil
  end

  it "should be able to create an more complex instance" do
    expect(described_class.new(:name => 'agg0',
                        :availability_zone => 'myzone',
                        :metadata => "a=b, c=d",
                        :hosts => "host1")).to_not be_nil
  end

  it "should be able to create an more complex instance with multiple hosts" do
    expect(described_class.new(:name => 'agg0',
                        :availability_zone => 'myzone',
                        :metadata => "a=b, c=d",
                        :hosts => "host1, host2")).to_not be_nil
  end

  it "should be able to create an more complex instance with hash for metadata" do
    expect(described_class.new(:name => 'agg0',
                        :availability_zone => 'myzone',
                        :metadata => { 'a' => 'b', 'c' => 'd' },
                        :hosts => "host1, host2")).to_not be_nil
  end

  it "should be able to create an more complex instance with hash for metadata and values containing commas" do
    expect(described_class.new(:name => 'agg0',
                        :availability_zone => 'myzone',
                        :metadata => { 'a' => 'b,e,f,g', 'c' => 'd,h,i,j' },
                        :hosts => "host1, host2")).to_not be_nil
  end

  it "should be able to create a instance and have the default values" do
    c = described_class.new(:name => 'agg0')
    expect(c[:name]).to eq("agg0")
    expect(c[:availability_zone]).to eq( nil)
    expect(c[:metadata]).to eq(nil)
    expect(c[:hosts]).to eq(nil)
  end

  it "should return the given values" do
    c = described_class.new(:name => 'agg0',
                            :availability_zone => 'myzone',
                            :metadata => "  a  =  b  , c=  d  ",
                            :hosts => "  host1, host2    ")
    expect(c[:name]).to eq("agg0")
    expect(c[:availability_zone]).to eq("myzone")
    expect(c[:metadata]).to eq({"a" => "b", "c" => "d"})
    expect(c[:hosts]).to eq(["host1" , "host2"])
  end

  it "should return the given values with hash for metadata" do
    c = described_class.new(:name => 'agg0',
                            :availability_zone => 'myzone',
                            :metadata => { 'a' => 'b', 'c' => 'd' },,
                            :hosts => "  host1, host2    ")
    expect(c[:name]).to eq("agg0")
    expect(c[:availability_zone]).to eq("myzone")
    expect(c[:metadata]).to eq({"a" => "b", "c" => "d"})
    expect(c[:hosts]).to eq(["host1" , "host2"])
  end

  it "should return the given values with hash for metadata and values containing commas" do
    c = described_class.new(:name => 'agg0',
                            :availability_zone => 'myzone',
                            :metadata => { 'a' => 'b,e,f,g', 'c' => 'd,h,i,j' },
                            :hosts => "  host1, host2    ")
    expect(c[:name]).to eq("agg0")
    expect(c[:availability_zone]).to eq("myzone")
    expect(c[:metadata]).to eq({"a" => "b", "c" => "d"})
    expect(c[:hosts]).to eq(["host1" , "host2"])
  end

  it "should return the given values" do
    c = described_class.new(:name => 'agg0',
                            :availability_zone => "",
                            :metadata => "",
                            :hosts => "")
    expect(c[:name]).to eq("agg0")
    expect(c[:availability_zone]).to eq("")
    expect(c[:metadata]).to eq({})
    expect(c[:hosts]).to eq([])
  end

end