File: archive_spec.rb

package info (click to toggle)
puppet-module-voxpupuli-archive 7.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 744 kB
  • sloc: ruby: 2,483; sh: 10; makefile: 4
file content (133 lines) | stat: -rw-r--r-- 3,062 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# frozen_string_literal: true

require 'spec_helper'

describe 'archive' do
  context 'RHEL' do
    let(:facts) do
      {
        os: { family: 'RedHat' },
        operatingsystem: 'RedHat',
        puppetversion: '4.4.0'
      }
    end

    context 'default' do
      it { is_expected.not_to contain_package('7zip') }
      it { is_expected.not_to contain_file('/opt/awscli-bundle') }
      it { is_expected.not_to contain_archive('awscli-bundle.zip') }
      it { is_expected.not_to contain_exec('install_aws_cli') }
      it { is_expected.to compile.with_all_deps }
      it { is_expected.to contain_class('archive::params') }
    end

    context 'with aws_cli' do
      let(:params) do
        {
          aws_cli_install: true
        }
      end

      it { is_expected.to contain_file('/opt/awscli-bundle') }
      it { is_expected.to contain_archive('awscli-bundle.zip') }
      it { is_expected.to contain_exec('install_aws_cli') }
    end

    context 'with archives' do
      let(:params) do
        {
          archives: {
            '/tmp/foo.tar.gz' => { 'ensure' => 'present' }
          }
        }
      end

      it { is_expected.to contain_archive('/tmp/foo.tar.gz') }
    end
  end

  describe 'Windows' do
    let(:default_facts) do
      {
        os: { family: 'Windows' },
        operatingsystem: 'Windows',
        archive_windir: 'C:/staging'
      }
    end

    context 'default 7zip chcolatey package' do
      let(:facts) do
        {
          puppetversion: '4.4.0'
        }.merge(default_facts)
      end

      it do
        expect(subject).to contain_package('7zip').with(
          name: '7zip',
          provider: 'chocolatey'
        )
      end

      it { is_expected.not_to contain_archive('awscli-bundle.zip') }
    end

    context 'with 7zip msi package' do
      let(:facts) do
        {
          puppetversion: '3.4.3 (Puppet Enterprise 3.2.3)'
        }.merge(default_facts)
      end

      let(:params) do
        {
          seven_zip_name: '7-Zip 9.20 (x64 edition)',
          seven_zip_source: 'C:/Windows/Temp/7z920-x64.msi',
          seven_zip_provider: 'windows'
        }
      end

      it do
        expect(subject).to contain_package('7zip').with(
          name: '7-Zip 9.20 (x64 edition)',
          source: 'C:/Windows/Temp/7z920-x64.msi',
          provider: 'windows'
        )
      end
    end

    context 'without 7zip' do
      let(:facts) do
        {
          puppetversion: '3.4.3 (Puppet Enterprise 3.2.3)'
        }.merge(default_facts)
      end

      let(:params) do
        {
          seven_zip_provider: ''
        }
      end

      it { is_expected.not_to contain_package('7zip') }
    end

    context 'with archives' do
      let(:facts) do
        {
          archive_windir: 'C:/staging'
        }.merge(default_facts)
      end

      let(:params) do
        {
          archives: {
            'C:/staging/foo.zip' => { 'ensure' => 'present' }
          }
        }
      end

      it { is_expected.to contain_archive('C:/staging/foo.zip') }
    end
  end
end