summaryrefslogtreecommitdiff
path: root/spec/models/postgresql/detached_partition_spec.rb
blob: aaa99e842b48f6f034c1be68d91eae6a47ea5c02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Postgresql::DetachedPartition do
  describe '#ready_to_drop' do
    let_it_be(:drop_before) { Postgresql::DetachedPartition.create!(drop_after: 1.day.ago, table_name: 'old_table') }
    let_it_be(:drop_after) { Postgresql::DetachedPartition.create!(drop_after: 1.day.from_now, table_name: 'new_table') }

    it 'includes partitions that should be dropped before now' do
      expect(Postgresql::DetachedPartition.ready_to_drop.to_a).to include(drop_before)
    end

    it 'does not include partitions that should be dropped after now' do
      expect(Postgresql::DetachedPartition.ready_to_drop.to_a).not_to include(drop_after)
    end
  end
end