4 provider_class = Puppet::Type.type(:postgresql_conf).provider(:parsed)
6 describe provider_class do
7 let(:title) { 'postgresql_conf' }
9 conf_class = Puppet::Type.type(:postgresql_conf)
10 provider = conf_class.provider(:parsed)
11 conffile = tmpfilename('postgresql.conf')
12 provider.any_instance.stub(:target).and_return conffile
23 describe "simple configuration that should be allowed" do
24 it "should parse a simple ini line" do
25 expect(provider.parse_line("listen_addreses = '*'")).to eq(
26 { :name=>"listen_addreses", :value=>"*", :comment=>nil, :record_type=>:parsed }
30 it "should parse a simple ini line (2)" do
31 expect(provider.parse_line(" listen_addreses = '*'")).to eq(
32 { :name=>"listen_addreses", :value=>"*", :comment=>nil, :record_type=>:parsed }
36 it "should parse a simple ini line (3)" do
37 expect(provider.parse_line("listen_addreses = '*' # dont mind me")).to eq(
38 { :name=>"listen_addreses", :value=>"*", :comment=>"dont mind me", :record_type=>:parsed }
42 it "should parse a comment" do
43 expect(provider.parse_line("# dont mind me")).to eq(
44 { :line=>"# dont mind me", :record_type=>:comment }
48 it "should parse a comment (2)" do
49 expect(provider.parse_line(" \t# dont mind me")).to eq(
50 { :line=>" \t# dont mind me", :record_type=>:comment }
54 it "should allow includes" do
55 expect(provider.parse_line("include puppetextra")).to eq(
56 { :name=>"include", :value=>"puppetextra", :comment=>nil, :record_type=>:parsed }
60 it "should allow numbers through without quotes" do
61 expect(provider.parse_line("wal_keep_segments = 32")).to eq(
62 { :name=>"wal_keep_segments", :value=>"32", :comment=>nil, :record_type=>:parsed }
66 it "should allow blanks through " do
67 expect(provider.parse_line("")).to eq(
68 { :line=>"", :record_type=>:blank }
72 it "should parse keys with dots " do
73 expect(provider.parse_line("auto_explain.log_min_duration = 1ms")).to eq(
74 { :name => "auto_explain.log_min_duration", :value => "1ms", :comment => nil, :record_type => :parsed }
79 describe "configuration that should be set" do
80 it "should set comment lines" do
81 expect(provider.to_line({ :line=>"# dont mind me", :record_type=>:comment })).to eq(
86 it "should set blank lines" do
87 expect(provider.to_line({ :line=>"", :record_type=>:blank })).to eq(
92 it "should set simple configuration" do
93 expect(provider.to_line({:name=>"listen_addresses", :value=>"*", :comment=>nil, :record_type=>:parsed })).to eq(
94 "listen_addresses = '*'"
98 it "should set simple configuration with period in name" do
99 expect(provider.to_line({:name => "auto_explain.log_min_duration", :value => '100ms', :comment => nil, :record_type => :parsed })).to eq(
100 "auto_explain.log_min_duration = 100ms"
104 it "should set simple configuration even with comments" do
105 expect(provider.to_line({:name=>"listen_addresses", :value=>"*", :comment=>'dont mind me', :record_type=>:parsed })).to eq(
106 "listen_addresses = '*' # dont mind me"
110 it 'should quote includes' do
111 expect(provider.to_line( {:name=>"include", :value=>"puppetextra", :comment=>nil, :record_type=>:parsed })).to eq(
112 "include 'puppetextra'"
116 it 'should quote multiple words' do
117 expect(provider.to_line( {:name=>"archive_command", :value=>"rsync up", :comment=>nil, :record_type=>:parsed })).to eq(
118 "archive_command = 'rsync up'"
122 it 'shouldn\'t quote numbers' do
123 expect(provider.to_line( {:name=>"wal_segments", :value=>"32", :comment=>nil, :record_type=>:parsed })).to eq(
128 it "should allow numbers" do
129 expect(provider.to_line( {:name=>"integer", :value=>42, :comment=>nil, :record_type=>:parsed })).to eq(
134 it "should allow floats" do
135 expect(provider.to_line( {:name=>"float", :value=>2.71828182845, :comment=>nil, :record_type=>:parsed })).to eq(
136 "float = 2.71828182845"
140 it "quotes addresses" do
141 expect(provider.to_line( {:name=>"listen_addresses", :value=>"0.0.0.0", :comment=>nil, :record_type=>:parsed })).to eq(
142 "listen_addresses = '0.0.0.0'"