diff options
Diffstat (limited to 'spec/models/loose_foreign_keys')
-rw-r--r-- | spec/models/loose_foreign_keys/modification_tracker_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/loose_foreign_keys/turbo_modification_tracker_spec.rb | 23 |
2 files changed, 31 insertions, 6 deletions
diff --git a/spec/models/loose_foreign_keys/modification_tracker_spec.rb b/spec/models/loose_foreign_keys/modification_tracker_spec.rb index 069ccf85141..afc62f28f92 100644 --- a/spec/models/loose_foreign_keys/modification_tracker_spec.rb +++ b/spec/models/loose_foreign_keys/modification_tracker_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -RSpec.describe LooseForeignKeys::ModificationTracker do +RSpec.describe LooseForeignKeys::ModificationTracker, feature_category: :database do subject(:tracker) { described_class.new } describe '#over_limit?' do - it 'is true when deletion MAX_DELETES is exceeded' do - stub_const('LooseForeignKeys::ModificationTracker::MAX_DELETES', 5) + it 'is true when deletion max_deletes is exceeded' do + expect(tracker).to receive(:max_deletes).and_return(5) tracker.add_deletions('issues', 10) expect(tracker).to be_over_limit @@ -20,7 +20,7 @@ RSpec.describe LooseForeignKeys::ModificationTracker do end it 'is true when deletion MAX_UPDATES is exceeded' do - stub_const('LooseForeignKeys::ModificationTracker::MAX_UPDATES', 5) + expect(tracker).to receive(:max_updates).and_return(5) tracker.add_updates('issues', 3) tracker.add_updates('issues', 4) @@ -36,9 +36,11 @@ RSpec.describe LooseForeignKeys::ModificationTracker do it 'is true when max runtime is exceeded' do monotonic_time_before = 1 # this will be the start time - monotonic_time_after = described_class::MAX_RUNTIME.to_i + 1 # this will be returned when over_limit? is called + monotonic_time_after = 31 # this will be returned when over_limit? is called - allow(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(monotonic_time_before, monotonic_time_after) + expect(Gitlab::Metrics::System).to receive(:monotonic_time).and_return( + monotonic_time_before, monotonic_time_after + ) tracker diff --git a/spec/models/loose_foreign_keys/turbo_modification_tracker_spec.rb b/spec/models/loose_foreign_keys/turbo_modification_tracker_spec.rb new file mode 100644 index 00000000000..0916a0845f5 --- /dev/null +++ b/spec/models/loose_foreign_keys/turbo_modification_tracker_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe LooseForeignKeys::TurboModificationTracker, feature_category: :database do + subject(:tracker) { described_class.new } + + let(:normal_tracker) { LooseForeignKeys::ModificationTracker.new } + + context 'with limits should be higher than LooseForeignKeys::ModificationTracker' do + it 'expect max_deletes to be equal or higher' do + expect(tracker.max_deletes).to be >= normal_tracker.max_deletes + end + + it 'expect max_updates to be equal or higher' do + expect(tracker.max_updates).to be >= normal_tracker.max_updates + end + + it 'expect max_runtime to be equal or higher' do + expect(tracker.max_runtime).to be >= normal_tracker.max_runtime + end + end +end |