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

transaction_timeout_settings_spec.rb « database « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5b68f9a3757953ebf67dd2ff669d752ca9ca5987 (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
33
34
35
36
37
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Database::TransactionTimeoutSettings, feature_category: :pods do
  let(:connection) { ActiveRecord::Base.connection }

  subject { described_class.new(connection) }

  after(:all) do
    described_class.new(ActiveRecord::Base.connection).restore_timeouts
  end

  describe '#disable_timeouts' do
    it 'sets timeouts to 0' do
      subject.disable_timeouts

      expect(current_timeout).to eq("0")
    end
  end

  describe '#restore_timeouts' do
    before do
      subject.disable_timeouts
    end

    it 'resets value' do
      expect(connection).to receive(:execute).with('RESET idle_in_transaction_session_timeout').and_call_original

      subject.restore_timeouts
    end
  end

  def current_timeout
    connection.execute("show idle_in_transaction_session_timeout").first['idle_in_transaction_session_timeout']
  end
end