Sha256: 161349507ffbdd48f838da1346a5dc0dafb6485b7ba03167c8796c60fdbcb0fc
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
require File.expand_path('../../spec_helper', __FILE__) require 'fog' describe Chef::Knife::S3Source do before(:each) do @bucket_name = 'my.bucket' @test_file_path = 'path/to/file.pem' @test_file_content = "TEST CONTENT\n" Fog.mock! { aws_access_key_id: 'aws_access_key_id', aws_secret_access_key: 'aws_secret_access_key' }.each do |key, value| Chef::Config[:knife][key] = value end fog = Fog::Storage::AWS.new( aws_access_key_id: 'aws_access_key_id', aws_secret_access_key: 'aws_secret_access_key' ) test_dir_obj = fog.directories.create('key' => @bucket_name) test_file_obj = test_dir_obj.files.create('key' => @test_file_path) test_file_obj.body = @test_file_content test_file_obj.save @s3_connection = double(Fog::Storage::AWS) @s3_source = Chef::Knife::S3Source.new @s3_source.url = "s3://#{@bucket_name}/#{@test_file_path}" end it 'converts URI to path with leading / removed' do @s3_source.instance_eval { path } @s3_source.instance_eval { path }.should eq(@test_file_path) end it 'correctly retrieves the bucket name from the URI' do @s3_source.instance_eval { bucket } @s3_source.instance_eval { bucket }.should eq(@bucket_name) end it 'gets back the correct bucket contents' do @s3_source.body.should eq(@test_file_content) end it 'gets back a bucket object with bucket_obj' do @s3_source.instance_eval { bucket_obj } @s3_source.instance_eval { bucket_obj }.should be_kind_of(Fog::Storage::AWS::Directory) end end
Version data entries
4 entries across 4 versions & 1 rubygems