File: collectd_real_version_spec.rb

package info (click to toggle)
puppet-module-voxpupuli-collectd 11.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,308 kB
  • sloc: ruby: 8,119; python: 30; sh: 10; makefile: 4
file content (25 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download | duplicates (2)
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
require 'spec_helper'

describe 'collectd_version', type: :fact do
  before { Facter.clear }
  after { Facter.clear }

  it 'is 5.1.0 according to output' do
    Facter::Util::Resolution.stubs(:which).with('collectd').returns('/usr/sbin/collectd')
    sample_collectd_help = File.read(fixtures('facts', 'collectd_help'))
    Facter::Util::Resolution.stubs(:exec).with('collectd -h').returns(sample_collectd_help)
    expect(Facter.fact(:collectd_version).value).to eq('5.1.0')
  end

  it 'is 5.1.0.git according to output' do
    Facter::Util::Resolution.stubs(:which).with('collectd').returns('/usr/sbin/collectd')
    sample_collectd_help_git = File.read(fixtures('facts', 'collectd_help_git'))
    Facter::Util::Resolution.stubs(:exec).with('collectd -h').returns(sample_collectd_help_git)
    expect(Facter.fact(:collectd_version).value).to eq('5.1.0.git')
  end

  it 'is not defined if collectd not installed' do
    Facter::Util::Resolution.stubs(:which).with('collectd').returns(nil)
    expect(Facter.fact(:collectd_version).value).to be_nil
  end
end