Skip to content

Commit

Permalink
[Enhance tests][Files & Directory scenarios] Test get nested director…
Browse files Browse the repository at this point in the history
…ies and files in nested directoryC
  • Loading branch information
chushenmeshile authored and xiaozhu36 committed Jun 17, 2020
1 parent 6984129 commit 22f297a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/fog/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,34 @@
system("aliyun oss mb oss://#{@conn.aliyun_oss_bucket} > /dev/null")
end

it 'Should get nested directories and files in nested directory' do
# nested directories
system("aliyun oss mkdir oss://#{@conn.aliyun_oss_bucket}/test_dir/dir1/dir2/dir3 > /dev/null")
directory = @conn.directories.get(@conn.aliyun_oss_bucket)
files = directory.files
expect(files.length).to eq(1)
expect(files.empty?).to eq(false)
file=files.get('test_dir/dir1/dir2/dir3/')
expect(file.key).to eq("test_dir/dir1/dir2/dir3/")
file.destroy
# nested files in nested directory
file = Tempfile.new('fog-upload-file')
file.write("Hello World!")
begin
system("aliyun oss mkdir oss://#{@conn.aliyun_oss_bucket}/test_dir/dir1/dir2 > /dev/null")
system("aliyun oss appendfromfile #{file.path} oss://#{@conn.aliyun_oss_bucket}/test_dir/dir1/dir2/test_file > /dev/null")
files = @conn.directories.get(@conn.aliyun_oss_bucket).files
expect(files.length).to eq(2)
expect(files.empty?).to eq(false)
expect(files.get("test_dir/dir1/dir2/").key).to eq("test_dir/dir1/dir2/")
expect(files.get("test_dir/dir1/dir2/test_file").key).to eq("test_dir/dir1/dir2/test_file")
files.get("test_dir/dir1/dir2/").destroy
files.get("test_dir/dir1/dir2/test_file").destroy
ensure
file.close
file.unlink
end
end
it 'test get file that not exists' do
directory = @conn.directories.get(@conn.aliyun_oss_bucket)
files = directory.files
Expand Down

0 comments on commit 22f297a

Please sign in to comment.