File: tar_spec.rb

package info (click to toggle)
puppet 4.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,736 kB
  • ctags: 14,616
  • sloc: ruby: 236,754; xml: 1,586; sh: 1,178; lisp: 299; sql: 103; yacc: 72; makefile: 52
file content (31 lines) | stat: -rw-r--r-- 1,212 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
26
27
28
29
30
31
require 'spec_helper'
require 'puppet/module_tool/tar'

describe Puppet::ModuleTool::Tar do

  it "uses tar when present and not on Windows" do
    Facter.stubs(:value).with('osfamily').returns 'ObscureLinuxDistro'
    Puppet::Util.stubs(:which).with('tar').returns '/usr/bin/tar'
    Puppet::Util::Platform.stubs(:windows?).returns false

    expect(described_class.instance).to be_a_kind_of Puppet::ModuleTool::Tar::Gnu
  end

  it "falls back to minitar when it and zlib are present" do
    Facter.stubs(:value).with('osfamily').returns 'Windows'
    Puppet::Util.stubs(:which).with('tar')
    Puppet::Util::Platform.stubs(:windows?).returns true
    Puppet.stubs(:features).returns(stub(:minitar? => true, :zlib? => true))

    expect(described_class.instance).to be_a_kind_of Puppet::ModuleTool::Tar::Mini
  end

  it "fails when there is no possible implementation" do
    Facter.stubs(:value).with('osfamily').returns 'Windows'
    Puppet::Util.stubs(:which).with('tar')
    Puppet::Util::Platform.stubs(:windows?).returns true
    Puppet.stubs(:features).returns(stub(:minitar? => false, :zlib? => false))

    expect { described_class.instance }.to raise_error RuntimeError, /No suitable tar/
  end
end