|
12 | 12 | stub_const('Gitlab::ImportExport::FileImporter::MAX_RETRIES', 0)
|
13 | 13 | allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
|
14 | 14 | allow_any_instance_of(Gitlab::ImportExport::CommandLineUtil).to receive(:untar_zxf).and_return(true)
|
15 |
| - |
| 15 | + allow(SecureRandom).to receive(:hex).and_return('abcd') |
16 | 16 | setup_files
|
17 |
| - |
18 |
| - described_class.import(archive_file: '', shared: shared) |
19 | 17 | end
|
20 | 18 |
|
21 | 19 | after do
|
22 | 20 | FileUtils.rm_rf(export_path)
|
23 | 21 | end
|
24 | 22 |
|
25 |
| - it 'removes symlinks in root folder' do |
26 |
| - expect(File.exist?(symlink_file)).to be false |
27 |
| - end |
| 23 | + context 'normal run' do |
| 24 | + before do |
| 25 | + described_class.import(archive_file: '', shared: shared) |
| 26 | + end |
28 | 27 |
|
29 |
| - it 'removes hidden symlinks in root folder' do |
30 |
| - expect(File.exist?(hidden_symlink_file)).to be false |
31 |
| - end |
| 28 | + it 'removes symlinks in root folder' do |
| 29 | + expect(File.exist?(symlink_file)).to be false |
| 30 | + end |
| 31 | + |
| 32 | + it 'removes hidden symlinks in root folder' do |
| 33 | + expect(File.exist?(hidden_symlink_file)).to be false |
| 34 | + end |
| 35 | + |
| 36 | + it 'removes symlinks in subfolders' do |
| 37 | + expect(File.exist?(subfolder_symlink_file)).to be false |
| 38 | + end |
32 | 39 |
|
33 |
| - it 'removes symlinks in subfolders' do |
34 |
| - expect(File.exist?(subfolder_symlink_file)).to be false |
| 40 | + it 'does not remove a valid file' do |
| 41 | + expect(File.exist?(valid_file)).to be true |
| 42 | + end |
| 43 | + |
| 44 | + it 'creates the file in the right subfolder' do |
| 45 | + expect(shared.export_path).to include('test/abcd') |
| 46 | + end |
35 | 47 | end
|
36 | 48 |
|
37 |
| - it 'does not remove a valid file' do |
38 |
| - expect(File.exist?(valid_file)).to be true |
| 49 | + context 'error' do |
| 50 | + before do |
| 51 | + allow_any_instance_of(described_class).to receive(:wait_for_archived_file).and_raise(StandardError) |
| 52 | + described_class.import(archive_file: '', shared: shared) |
| 53 | + end |
| 54 | + |
| 55 | + it 'removes symlinks in root folder' do |
| 56 | + expect(File.exist?(symlink_file)).to be false |
| 57 | + end |
| 58 | + |
| 59 | + it 'removes hidden symlinks in root folder' do |
| 60 | + expect(File.exist?(hidden_symlink_file)).to be false |
| 61 | + end |
| 62 | + |
| 63 | + it 'removes symlinks in subfolders' do |
| 64 | + expect(File.exist?(subfolder_symlink_file)).to be false |
| 65 | + end |
| 66 | + |
| 67 | + it 'does not remove a valid file' do |
| 68 | + expect(File.exist?(valid_file)).to be true |
| 69 | + end |
39 | 70 | end
|
40 | 71 |
|
41 | 72 | def setup_files
|
|
0 commit comments