diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/database/transaction/context_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/database/transaction/context_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database/transaction/context_spec.rb | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/spec/lib/gitlab/database/transaction/context_spec.rb b/spec/lib/gitlab/database/transaction/context_spec.rb index 65d52b4d099..37cfc841d48 100644 --- a/spec/lib/gitlab/database/transaction/context_spec.rb +++ b/spec/lib/gitlab/database/transaction/context_spec.rb @@ -62,30 +62,32 @@ RSpec.describe Gitlab::Database::Transaction::Context do it { expect(data[:queries]).to eq(['SELECT 1', 'SELECT * FROM users']) } end - describe '#duration' do + describe '#track_backtrace' do before do - subject.set_start_time + subject.track_backtrace(caller) end - it { expect(subject.duration).to be >= 0 } - end + it { expect(data[:backtraces]).to be_a(Array) } + it { expect(data[:backtraces]).to all(be_a(Array)) } + it { expect(data[:backtraces].length).to eq(1) } + it { expect(data[:backtraces][0][0]).to be_a(String) } - context 'when depth is low' do - it 'does not log data upon COMMIT' do - expect(subject).not_to receive(:application_info) + it 'appends the backtrace' do + subject.track_backtrace(caller) - subject.commit + expect(data[:backtraces].length).to eq(2) + expect(subject.backtraces).to be_a(Array) + expect(subject.backtraces).to all(be_a(Array)) + expect(subject.backtraces[1][0]).to be_a(String) end + end - it 'does not log data upon ROLLBACK' do - expect(subject).not_to receive(:application_info) - - subject.rollback + describe '#duration' do + before do + subject.set_start_time end - it '#should_log? returns false' do - expect(subject.should_log?).to be false - end + it { expect(subject.duration).to be >= 0 } end shared_examples 'logs transaction data' do @@ -116,17 +118,9 @@ RSpec.describe Gitlab::Database::Transaction::Context do end end - context 'when depth exceeds threshold' do - before do - subject.set_depth(described_class::LOG_DEPTH_THRESHOLD + 1) - end - - it_behaves_like 'logs transaction data' - end - context 'when savepoints count exceeds threshold' do before do - data[:savepoints] = described_class::LOG_SAVEPOINTS_THRESHOLD + 1 + data[:savepoints] = 1 end it_behaves_like 'logs transaction data' |