loading
Generated 2022-01-05T10:37:15-07:00

All Files ( 92.0% covered at 4.28 hits/line )

1 files in total.
25 relevant lines, 23 lines covered and 2 lines missed. ( 92.0% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line
spec/unit/recipes/resource_spec.rb 92.00 % 61 25 23 2 4.28

spec/unit/recipes/resource_spec.rb

92.0% lines covered

25 relevant lines. 23 lines covered and 2 lines missed.
    
  1. # frozen_string_literal: true
  2. #
  3. # Cookbook:: remote_file_s3
  4. # Spec:: resource
  5. #
  6. # Copyright:: 2018, Matt Kulka
  7. 1 require 'spec_helper'
  8. 1 describe 'remote_file_s3_test::default' do
  9. 1 %w(ubuntu/20.04 centos/7.4.1708 windows/2019 mac_os_x/10.15).each do |p|
  10. 4 platform(*p.split('/'))
  11. 4 context "when on #{p}" do
  12. 4 default_attributes['remote_file_s3_test'] = {
  13. bucket: 'foo',
  14. file: 'bar',
  15. region: 'us-west-2',
  16. aws_access_key_id: 'testkeyid',
  17. aws_secret_access_key: 'testkey'
  18. }
  19. 24 let(:dir_path) { chef_run.node['platform'] == 'windows' ? 'c:/remote_file_s3' : '/tmp/remote_file_s3' }
  20. 4 it 'converges successfully' do
  21. 8 expect { chef_run }.to_not raise_error
  22. end
  23. 4 it 'creates directories to download file' do
  24. 4 expect(chef_run).to create_directory(dir_path)
  25. end
  26. 4 it 'creates test user' do
  27. 4 expect(chef_run).to create_user('otheruser')
  28. end
  29. 4 it 'creates test group' do
  30. 4 expect(chef_run).to create_group('otheruser') unless chef_run.node['platform'] == 'windows'
  31. end
  32. 4 it 'creates files to overwrite' do
  33. 4 expect(chef_run).to create_file("make #{dir_path}/existing_file_bad_ownership.txt")
  34. end
  35. 4 it 'creates new s3 file' do
  36. 4 expect(chef_run).to create_remote_file_s3("#{dir_path}/new_file.txt")
  37. expect(chef_run).to create_remote_file_s3("#{dir_path}/file_no_owner.txt")
  38. end
  39. 4 it 'creates file to be overwritten' do
  40. 4 expect(chef_run).to create_file("#{dir_path}/existing_file_good_ownership.txt")
  41. end
  42. 4 it 'should overwrite existing file with new s3 file' do
  43. 4 expect(chef_run).to create_remote_file_s3("#{dir_path}/existing_file_good_ownership.txt")
  44. expect(chef_run).to create_remote_file_s3("#{dir_path}/existing_file_bad_ownership.txt")
  45. end
  46. end
  47. end
  48. end