|
2 | 2 |
|
3 | 3 | require 'spec_helper_acceptance'
|
4 | 4 |
|
| 5 | +# This tarball contains entries owned by gopher (501) rather than root. |
| 6 | +source_url = 'https://go.dev/dl/go1.10.4.darwin-amd64.tar.gz' |
| 7 | + |
| 8 | +newer_source_url = 'https://go.dev/dl/go1.19.1.darwin-amd64.tar.gz' |
| 9 | + |
5 | 10 | describe 'defined type golang::from_tarball' do
|
6 | 11 | context 'repeated root installs:' do
|
7 | 12 | context 'default ensure with 1.10.4 source' do
|
8 | 13 | it 'installs Go' do
|
9 |
| - idempotent_apply(<<~'PUPPET') |
| 14 | + idempotent_apply(<<~"PUPPET") |
10 | 15 | golang::from_tarball { '/opt/go':
|
11 |
| - source => 'https://go.dev/dl/go1.10.4.linux-amd64.tar.gz', |
| 16 | + source => '#{source_url}', |
12 | 17 | }
|
13 | 18 | PUPPET
|
14 | 19 | end
|
15 | 20 |
|
| 21 | + describe file('/opt/go') do |
| 22 | + it { is_expected.to be_directory } |
| 23 | + its(:mode) { is_expected.to eq '755' } |
| 24 | + its(:owner) { is_expected.to eq 'root' } |
| 25 | + end |
| 26 | + |
| 27 | + describe file('/opt/.go.source_url') do |
| 28 | + it { is_expected.to be_file } |
| 29 | + its(:mode) { is_expected.to eq '444' } |
| 30 | + its(:owner) { is_expected.to eq 'root' } |
| 31 | + its(:content) { is_expected.to include "\n#{source_url}\n" } |
| 32 | + end |
| 33 | + |
| 34 | + describe file('/opt/go/bin/go') do |
| 35 | + it { is_expected.to be_file } |
| 36 | + its(:mode) { is_expected.to eq '755' } |
| 37 | + its(:owner) { is_expected.to eq 'root' } |
| 38 | + end |
| 39 | + |
16 | 40 | describe file('/opt/go/VERSION') do
|
17 | 41 | its(:content) { is_expected.to eq 'go1.10.4' }
|
18 | 42 | end
|
19 | 43 | end
|
20 | 44 |
|
21 | 45 | context 'ensure => present' do
|
22 | 46 | it 'causes no changes' do
|
23 |
| - apply_manifest(<<~'PUPPET', catch_changes: true) |
| 47 | + apply_manifest(<<~"PUPPET", catch_changes: true) |
24 | 48 | golang::from_tarball { '/opt/go':
|
25 | 49 | ensure => present,
|
26 |
| - source => 'https://go.dev/dl/go1.10.4.linux-amd64.tar.gz', |
| 50 | + source => '#{source_url}', |
27 | 51 | }
|
28 | 52 | PUPPET
|
29 | 53 | end
|
30 | 54 |
|
| 55 | + describe file('/opt/.go.source_url') do |
| 56 | + it { is_expected.to be_file } |
| 57 | + its(:mode) { is_expected.to eq '444' } |
| 58 | + its(:owner) { is_expected.to eq 'root' } |
| 59 | + its(:content) { is_expected.to include "\n#{source_url}\n" } |
| 60 | + end |
| 61 | + |
31 | 62 | describe file('/opt/go/VERSION') do
|
32 | 63 | its(:content) { is_expected.to eq 'go1.10.4' }
|
33 | 64 | end
|
34 | 65 | end
|
35 | 66 |
|
36 |
| - context 'ensure => any_version with 1.19.1 source' do |
| 67 | + context 'ensure => any_version with newer source' do |
37 | 68 | it 'causes no changes' do
|
38 |
| - apply_manifest(<<~'PUPPET', catch_changes: true) |
| 69 | + apply_manifest(<<~"PUPPET", catch_changes: true) |
39 | 70 | golang::from_tarball { '/opt/go':
|
40 | 71 | ensure => any_version,
|
41 |
| - source => 'https://go.dev/dl/go1.19.1.linux-amd64.tar.gz', |
| 72 | + source => '#{newer_source_url}', |
42 | 73 | }
|
43 | 74 | PUPPET
|
44 | 75 | end
|
45 | 76 |
|
| 77 | + describe file('/opt/.go.source_url') do |
| 78 | + it { is_expected.to be_file } |
| 79 | + its(:mode) { is_expected.to eq '444' } |
| 80 | + its(:owner) { is_expected.to eq 'root' } |
| 81 | + its(:content) { is_expected.to include "\n#{source_url}\n" } |
| 82 | + end |
| 83 | + |
46 | 84 | describe file('/opt/go/VERSION') do
|
47 | 85 | its(:content) { is_expected.to eq 'go1.10.4' }
|
48 | 86 | end
|
49 | 87 | end
|
50 | 88 |
|
51 |
| - context 'ensure => present with 1.19.1 source' do |
| 89 | + context 'ensure => present with newer source' do |
52 | 90 | it 'causes changes' do
|
53 |
| - apply_manifest(<<~'PUPPET', expect_changes: true) |
| 91 | + apply_manifest(<<~"PUPPET", expect_changes: true) |
54 | 92 | golang::from_tarball { '/opt/go':
|
55 | 93 | ensure => present,
|
56 |
| - source => 'https://go.dev/dl/go1.19.1.linux-amd64.tar.gz', |
| 94 | + source => '#{newer_source_url}', |
57 | 95 | }
|
58 | 96 | PUPPET
|
59 | 97 | end
|
60 | 98 |
|
| 99 | + describe file('/opt/.go.source_url') do |
| 100 | + it { is_expected.to be_file } |
| 101 | + its(:mode) { is_expected.to eq '444' } |
| 102 | + its(:owner) { is_expected.to eq 'root' } |
| 103 | + its(:content) { is_expected.to include "\n#{newer_source_url}\n" } |
| 104 | + end |
| 105 | + |
61 | 106 | describe file('/opt/go/VERSION') do
|
62 | 107 | its(:content) { is_expected.to eq 'go1.19.1' }
|
63 | 108 | end
|
64 | 109 | end
|
65 | 110 |
|
66 | 111 | context 'ensure => absent' do
|
67 | 112 | it do
|
68 |
| - idempotent_apply(<<~'PUPPET') |
| 113 | + idempotent_apply(<<~"PUPPET") |
69 | 114 | golang::from_tarball { '/opt/go':
|
70 | 115 | ensure => absent,
|
71 |
| - source => 'https://go.dev/dl/go1.19.1.linux-amd64.tar.gz', |
| 116 | + source => '#{newer_source_url}', |
72 | 117 | }
|
73 | 118 | PUPPET
|
74 | 119 | end
|
75 | 120 |
|
| 121 | + describe file('/opt/go') do |
| 122 | + it { is_expected.not_to exist } |
| 123 | + end |
| 124 | + |
| 125 | + describe file('/opt/.go.source_url') do |
| 126 | + it { is_expected.not_to exist } |
| 127 | + end |
| 128 | + |
76 | 129 | describe file('/opt/go/VERSION') do
|
77 | 130 | it { is_expected.not_to exist }
|
78 | 131 | end
|
|
0 commit comments