File: go_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 (84 lines) | stat: -rw-r--r-- 2,152 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
# frozen_string_literal: true

require 'spec_helper'

describe 'archive::go' do
  let(:facts) { { os: { family: 'RedHat' }, puppetversion: '4.4.0' } }

  # Mock Puppet V4 API ruby function with a puppet language function equivalent
  let(:pre_condition) do
    <<-PUPPET
    function archive::go_md5(String $username, String $password, String $file, Stdlib::HTTPUrl $url) {
      return '0d4f4b4b039c10917cfc49f6f6be71e4'
    }
    PUPPET
  end

  context 'go archive with defaults' do
    let(:title) { '/opt/app/example.zip' }
    let(:params) do
      {
        server: 'home.lan',
        port: 8081,
        url_path: 'go/example.zip',
        md5_url_path: 'go/example.zip/checksum',
        username: 'username',
        password: 'password'
      }
    end

    it do
      expect(subject).to contain_archive('/opt/app/example.zip').with(
        path: '/opt/app/example.zip',
        source: 'http://home.lan:8081/go/example.zip',
        checksum: '0d4f4b4b039c10917cfc49f6f6be71e4',
        checksum_type: 'md5'
      )
    end

    it do
      expect(subject).to contain_file('/opt/app/example.zip').with(
        owner: '0',
        group: '0',
        mode: '0640',
        require: 'Archive[/opt/app/example.zip]'
      )
    end
  end

  context 'go archive with path' do
    let(:title) { 'example.zip' }
    let(:params) do
      {
        archive_path: '/opt/app',
        server: 'home.lan',
        port: 8081,
        url_path: 'go/example.zip',
        md5_url_path: 'go/example.zip/checksum',
        username: 'username',
        password: 'password',
        owner: 'app',
        group: 'app',
        mode: '0400'
      }
    end

    it do
      expect(subject).to contain_archive('/opt/app/example.zip').with(
        path: '/opt/app/example.zip',
        source: 'http://home.lan:8081/go/example.zip',
        checksum: '0d4f4b4b039c10917cfc49f6f6be71e4',
        checksum_type: 'md5'
      )
    end

    it do
      expect(subject).to contain_file('/opt/app/example.zip').with(
        owner: 'app',
        group: 'app',
        mode: '0400',
        require: 'Archive[/opt/app/example.zip]'
      )
    end
  end
end