license_check_spec.rb 1.14 KB
Newer Older
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 33
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SystemCheck::Geo::LicenseCheck do
  describe '#check?' do
    using RSpec::Parameterized::TableSyntax

    where(:primary, :geo_enabled, :license_allows, :check_result, :pass_message) do
      true | true | true | true | ''
      true | true | false | false | ''
      true | false | true | true | 'License supports Geo, but Geo is not enabled'
      true | false | false | true | 'License does not support Geo, and Geo is not enabled'
      false | true | true | true | ''
      false | true | false | true | 'License only required on a primary site'
      false | false | true | true | ''
      false | false | false | true | ''
    end

    with_them do
      before do
        allow(Gitlab::Geo).to receive(:primary?).and_return(primary)
        allow(Gitlab::Geo).to receive(:enabled?).and_return(geo_enabled)
        allow(Gitlab::Geo).to receive(:license_allows?).and_return(license_allows)
      end

      it 'checks the license' do
        expect(subject.check?).to eq(check_result)
        expect(described_class.check_pass).to eq(pass_message) if check_result
      end
    end
  end
end