Skip to content

Commit aa6cb8e

Browse files
jnunemakerclaude
andcommitted
Add more comprehensive ActorLimit sync tests
- Test incremental sync: 20 actors synced, then 21st added and synced - Test that direct enable operations still enforce limits after sync - Use 10/20 actor ratio to better simulate realistic Cloud scenario Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 1a886a0 commit aa6cb8e

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

spec/flipper/adapters/sync/synchronizer_spec.rb

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,49 @@
127127
end
128128

129129
context 'with ActorLimit adapter wrapping local' do
130-
let(:limit) { 5 }
130+
let(:limit) { 10 }
131131
let(:limited_local) { Flipper::Adapters::ActorLimit.new(local, limit) }
132132
let(:limited_local_flipper) { Flipper.new(limited_local) }
133133

134134
subject { described_class.new(limited_local, remote, instrumenter: instrumenter) }
135135

136136
it 'syncs actors even when remote has more actors than local limit' do
137137
# Remote has more actors than local limit allows
138-
10.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") }
138+
20.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") }
139139

140140
# This should NOT raise - sync should bypass actor limits
141141
expect { subject.call }.not_to raise_error
142142

143143
# All actors should be synced
144-
expect(limited_local_flipper[:search].actors_value.size).to eq(10)
144+
expect(limited_local_flipper[:search].actors_value.size).to eq(20)
145+
end
146+
147+
it 'syncs new actors added to remote after initial sync' do
148+
# Initial state: remote has 20 actors, local limit is 10
149+
20.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") }
150+
151+
# First sync - should work despite exceeding limit
152+
subject.call
153+
expect(limited_local_flipper[:search].actors_value.size).to eq(20)
154+
155+
# Add a 21st actor to remote (simulating Cloud adding a new actor)
156+
remote_flipper[:search].enable_actor Flipper::Actor.new("User;20")
157+
158+
# Sync again - should pick up the new actor
159+
expect { subject.call }.not_to raise_error
160+
expect(limited_local_flipper[:search].actors_value.size).to eq(21)
161+
expect(limited_local_flipper[:search].actors_value).to include("User;20")
162+
end
163+
164+
it 'still enforces limit for direct enable operations' do
165+
# First sync 20 actors from remote
166+
20.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") }
167+
subject.call
168+
169+
# Direct enable should still fail because we're over limit
170+
expect {
171+
limited_local_flipper[:search].enable_actor Flipper::Actor.new("User;new")
172+
}.to raise_error(Flipper::Adapters::ActorLimit::LimitExceeded)
145173
end
146174
end
147175
end

0 commit comments

Comments
 (0)