File: diff_spec.rb

package info (click to toggle)
puppet-agent 7.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,092 kB
  • sloc: ruby: 245,074; sh: 456; makefile: 38; xml: 33
file content (46 lines) | stat: -rw-r--r-- 1,475 bytes parent folder | download | duplicates (3)
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
require 'spec_helper'
require 'puppet/util/diff'
require 'puppet/util/execution'

describe Puppet::Util::Diff do
  let(:baz_output) { Puppet::Util::Execution::ProcessOutput.new('baz', 0) }

  describe ".diff" do
    it "should execute the diff command with arguments" do
      Puppet[:diff] = 'foo'
      Puppet[:diff_args] = 'bar'

      expect(Puppet::Util::Execution).to receive(:execute)
        .with(['foo', 'bar', 'a', 'b'], {:failonfail => false, :combine => false})
        .and_return(baz_output)
      expect(subject.diff('a', 'b')).to eq('baz')
    end

    it "should execute the diff command with multiple arguments" do
      Puppet[:diff] = 'foo'
      Puppet[:diff_args] = 'bar qux'

      expect(Puppet::Util::Execution).to receive(:execute)
        .with(['foo', 'bar', 'qux', 'a', 'b'], anything)
        .and_return(baz_output)
      expect(subject.diff('a', 'b')).to eq('baz')
    end

    it "should omit diff arguments if none are specified" do
      Puppet[:diff] = 'foo'
      Puppet[:diff_args] = ''

      expect(Puppet::Util::Execution).to receive(:execute)
        .with(['foo', 'a', 'b'], {:failonfail => false, :combine => false})
        .and_return(baz_output)
      expect(subject.diff('a', 'b')).to eq('baz')
    end

    it "should return empty string if the diff command is empty" do
      Puppet[:diff] = ''

      expect(Puppet::Util::Execution).not_to receive(:execute)
      expect(subject.diff('a', 'b')).to eq('')
    end
  end
end