discourse/migrations/spec/lib/common/set_store_spec.rb
Gerhard Schlager 53d7a756d6
DEV: Add Migrations::SetStore to work with nested sets of data (#33593)
There are concrete implementations for a simple set, a key-value store,
and nested sets with 2 or 3 keys. The API stays the same for all
implementations and the performances is more or less the same as without
the wrapper (at least with YJIT enabled).
2025-07-24 12:11:41 +02:00

28 lines
845 B
Ruby

# frozen_string_literal: true
RSpec.describe Migrations::SetStore do
describe ".create" do
it "returns a SimpleSet for depth 0" do
expect(described_class.create(0)).to be_a(::Migrations::SetStore::SimpleSet)
end
it "returns a KeyValueSet for depth 1" do
expect(described_class.create(1)).to be_a(::Migrations::SetStore::KeyValueSet)
end
it "returns a TwoKeySet for depth 2" do
expect(described_class.create(2)).to be_a(::Migrations::SetStore::TwoKeySet)
end
it "returns a ThreeKeySet for depth 3" do
expect(described_class.create(3)).to be_a(::Migrations::SetStore::ThreeKeySet)
end
it "raises an error for unsupported depths" do
expect { described_class.create(4) }.to raise_error(
ArgumentError,
"Unsupported nesting depth: 4",
)
end
end
end