Skip to content

Commit 149d08f

Browse files
committed
Add tests for MODULES-5651
1 parent 34f9f6a commit 149d08f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

spec/unit/puppet/provider/file_line/ruby_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,34 @@
235235
end
236236
end
237237
end
238+
describe 'MODULES-5651' do
239+
let(:params) { {
240+
line: 'LogLevel=notice',
241+
match: '^#LogLevel$',
242+
} }
243+
context "match, no line" do
244+
let(:content) { "#LogLevel\nstuff" }
245+
it 'requests changes' do
246+
expect(provider.exists?).to be_falsy
247+
end
248+
it 'replaces the match' do
249+
provider.create
250+
expect(File.read(tmpfile).chomp).to eq("LogLevel=notice\nstuff")
251+
end
252+
end
253+
context "match, line" do
254+
let(:content) { "#Loglevel\nLogLevel=notice\nstuff" }
255+
it 'does not request changes' do
256+
expect(provider.exists?).to be_truthy
257+
end
258+
end
259+
context "no match, line" do
260+
let(:content) { "LogLevel=notice\nstuff" }
261+
it 'does not request changes' do
262+
expect(provider.exists?).to be_truthy
263+
end
264+
end
265+
end
238266
end
239267
describe "#create" do
240268
context "when adding" do

0 commit comments

Comments
 (0)