|
131 | 131 | end
|
132 | 132 | end
|
133 | 133 | end
|
| 134 | + |
| 135 | + context 'as a non-root user' do |
| 136 | + context 'default ensure with 1.10.4 source' do |
| 137 | + it 'installs Go' do |
| 138 | + idempotent_apply(<<~"PUPPET") |
| 139 | + group { 'user': } |
| 140 | + user { 'user': |
| 141 | + home => '#{home}/user', |
| 142 | + gid => 'user', |
| 143 | + managehome => false, |
| 144 | + } |
| 145 | +
|
| 146 | + file { '#{home}/user': |
| 147 | + ensure => directory, |
| 148 | + owner => 'user', |
| 149 | + group => 'user', |
| 150 | + mode => '0755', |
| 151 | + } |
| 152 | +
|
| 153 | + golang::from_tarball { '#{home}/user/go-install': |
| 154 | + source => '#{source_url}', |
| 155 | + owner => 'user', |
| 156 | + group => 'user', |
| 157 | + mode => '0700', |
| 158 | + } |
| 159 | + PUPPET |
| 160 | + end |
| 161 | + |
| 162 | + describe file("#{home}/user/go-install") do |
| 163 | + it { is_expected.to be_directory } |
| 164 | + its(:mode) { is_expected.to eq '700' } |
| 165 | + its(:owner) { is_expected.to eq 'user' } |
| 166 | + its(:group) { is_expected.to eq 'user' } |
| 167 | + end |
| 168 | + |
| 169 | + describe file("#{home}/user/.go-install.source_url") do |
| 170 | + it { is_expected.to be_file } |
| 171 | + its(:mode) { is_expected.to eq '444' } |
| 172 | + its(:owner) { is_expected.to eq 'user' } |
| 173 | + its(:content) { is_expected.to include "\n#{source_url}\n" } |
| 174 | + end |
| 175 | + |
| 176 | + describe file("#{home}/user/go-install/bin/go") do |
| 177 | + it { is_expected.to be_file } |
| 178 | + its(:mode) { is_expected.to eq '755' } |
| 179 | + its(:owner) { is_expected.to eq 'user' } |
| 180 | + its(:group) { is_expected.to eq 'user' } |
| 181 | + end |
| 182 | + |
| 183 | + describe file("#{home}/user/go-install/VERSION") do |
| 184 | + its(:content) { is_expected.to eq 'go1.10.4' } |
| 185 | + its(:owner) { is_expected.to eq 'user' } |
| 186 | + its(:group) { is_expected.to eq 'user' } |
| 187 | + end |
| 188 | + end |
| 189 | + |
| 190 | + context 'cleans up' do |
| 191 | + it 'uninstalls Go' do |
| 192 | + idempotent_apply(<<~"PUPPET") |
| 193 | + golang::from_tarball { '#{home}/user/go-install': |
| 194 | + ensure => absent, |
| 195 | + source => '#{source_url}', |
| 196 | + } |
| 197 | + PUPPET |
| 198 | + end |
| 199 | + |
| 200 | + describe file("#{home}/user/go-install") do |
| 201 | + it { is_expected.not_to exist } |
| 202 | + end |
| 203 | + |
| 204 | + describe file("#{home}/user/.go-install.source_url") do |
| 205 | + it { is_expected.not_to exist } |
| 206 | + end |
| 207 | + end |
| 208 | + end |
134 | 209 | end
|
0 commit comments