-
# frozen_string_literal: true
-
-
#
-
# Cookbook:: remote_file_s3
-
# Spec:: resource
-
#
-
# Copyright:: 2018, Matt Kulka
-
-
1
require 'spec_helper'
-
-
1
describe 'remote_file_s3_test::default' do
-
1
%w(ubuntu/20.04 centos/7.4.1708 windows/2019 mac_os_x/10.15).each do |p|
-
4
platform(*p.split('/'))
-
-
4
context "when on #{p}" do
-
4
default_attributes['remote_file_s3_test'] = {
-
bucket: 'foo',
-
file: 'bar',
-
region: 'us-west-2',
-
aws_access_key_id: 'testkeyid',
-
aws_secret_access_key: 'testkey'
-
}
-
-
24
let(:dir_path) { chef_run.node['platform'] == 'windows' ? 'c:/remote_file_s3' : '/tmp/remote_file_s3' }
-
-
4
it 'converges successfully' do
-
8
expect { chef_run }.to_not raise_error
-
end
-
-
4
it 'creates directories to download file' do
-
4
expect(chef_run).to create_directory(dir_path)
-
end
-
-
4
it 'creates test user' do
-
4
expect(chef_run).to create_user('otheruser')
-
end
-
-
4
it 'creates test group' do
-
4
expect(chef_run).to create_group('otheruser') unless chef_run.node['platform'] == 'windows'
-
end
-
-
4
it 'creates files to overwrite' do
-
4
expect(chef_run).to create_file("make #{dir_path}/existing_file_bad_ownership.txt")
-
end
-
-
4
it 'creates new s3 file' do
-
4
expect(chef_run).to create_remote_file_s3("#{dir_path}/new_file.txt")
-
4
expect(chef_run).to create_remote_file_s3("#{dir_path}/file_no_owner.txt")
-
end
-
-
4
it 'creates file to be overwritten' do
-
4
expect(chef_run).to create_file("#{dir_path}/existing_file_good_ownership.txt")
-
end
-
-
4
it 'should overwrite existing file with new s3 file' do
-
4
expect(chef_run).to create_remote_file_s3("#{dir_path}/existing_file_good_ownership.txt")
-
4
expect(chef_run).to create_remote_file_s3("#{dir_path}/existing_file_bad_ownership.txt")
-
end
-
end
-
end
-
end