Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bundle_file_spec.rb « git « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 701febadc1b65ad67c47d30ea7c9ac8bab9e22a3 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Git::BundleFile do
  describe '.check!' do
    let(:valid_bundle) { Tempfile.new }
    let(:valid_bundle_path) { valid_bundle.path }
    let(:invalid_bundle_path) { Rails.root.join('spec/fixtures/malicious.bundle') }

    after do
      valid_bundle.close!
    end

    it 'returns nil for a valid bundle' do
      valid_bundle.write("# v2 git bundle\nfoo bar baz\n")
      valid_bundle.close

      expect(described_class.check!(valid_bundle_path)).to be_nil
    end

    it 'raises an exception for an invalid bundle' do
      expect do
        described_class.check!(invalid_bundle_path)
      end.to raise_error(described_class::InvalidBundleError)
    end
  end
end