summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/json/legacy_reader/file_spec.rb
blob: 9c7f41cbb89bb3eb0c3205a1725d24eccce6d0d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

require 'spec_helper'
require_relative 'shared_example.rb'

RSpec.describe Gitlab::ImportExport::JSON::LegacyReader::File do
  it_behaves_like 'import/export json legacy reader' do
    let(:valid_path) { 'spec/fixtures/lib/gitlab/import_export/light/project.json' }
    let(:data) { valid_path }
    let(:json_data) { Gitlab::Json.parse(File.read(valid_path)) }
  end

  describe '#exist?' do
    let(:legacy_reader) do
      described_class.new(path, relation_names: [])
    end

    subject { legacy_reader.exist? }

    context 'given valid path' do
      let(:path) { 'spec/fixtures/lib/gitlab/import_export/light/project.json' }

      it { is_expected.to be true }
    end

    context 'given invalid path' do
      let(:path) { 'spec/non-existing-folder/do-not-create-this-file.json' }

      it { is_expected.to be false }
    end
  end
end