Skip to content

Commit 57c3818

Browse files
Remove shouldFilter
1 parent 4110738 commit 57c3818

File tree

2 files changed

+0
-81
lines changed

2 files changed

+0
-81
lines changed

internal/integration/unified/client_entity.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,6 @@ func (es *eventSequencer) recordPooledEvent() {
8484
es.mu.Unlock()
8585
}
8686

87-
// shouldFilter returns true if the event at the given index should be filtered.
88-
func (es *eventSequencer) shouldFilter(eventType monitoringEventType, index int) bool {
89-
cutoff := es.cutoff.Load()
90-
if cutoff == 0 {
91-
return false
92-
}
93-
94-
es.mu.RLock()
95-
defer es.mu.RUnlock()
96-
97-
seqs, ok := es.seqByEventType[eventType]
98-
if !ok || index < 0 || index >= len(seqs) {
99-
return false
100-
}
101-
102-
return seqs[index] <= cutoff
103-
}
104-
10587
// clientEntity is a wrapper for a mongo.Client object that also holds additional information required during test
10688
// execution.
10789
type clientEntity struct {

internal/integration/unified/client_entity_test.go

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package unified
88

99
import (
10-
"sync/atomic"
1110
"testing"
1211

1312
"go.mongodb.org/mongo-driver/v2/event"
@@ -170,65 +169,3 @@ func Test_eventSequencer_setCutoff(t *testing.T) {
170169
assert.Equal(t, int64(3), client.eventSequencer.counter.Load(), "counter should be 3")
171170
assert.Equal(t, int64(2), client.eventSequencer.cutoff.Load(), "cutoff should still be 2")
172171
}
173-
174-
func Test_eventSequencer_shouldFilter(t *testing.T) {
175-
es := &eventSequencer{
176-
seqByEventType: map[monitoringEventType][]int64{
177-
serverDescriptionChangedEvent: {1, 2, 3, 4, 5},
178-
},
179-
}
180-
es.counter = atomic.Int64{}
181-
es.counter.Store(5)
182-
183-
tests := []struct {
184-
name string
185-
cutoff int64
186-
eventType monitoringEventType
187-
index int
188-
expected bool
189-
}{
190-
{
191-
name: "no cutoff",
192-
cutoff: 0,
193-
eventType: serverDescriptionChangedEvent,
194-
index: 0,
195-
expected: false,
196-
},
197-
{
198-
name: "before cutoff",
199-
cutoff: 3,
200-
eventType: serverDescriptionChangedEvent,
201-
index: 0,
202-
expected: true, // seq=1 <= 3
203-
},
204-
{
205-
name: "at cutoff",
206-
cutoff: 3,
207-
eventType: serverDescriptionChangedEvent,
208-
index: 2,
209-
expected: true, // seq=3 <= 3
210-
},
211-
{
212-
name: "after cutoff",
213-
cutoff: 3,
214-
eventType: serverDescriptionChangedEvent,
215-
index: 3,
216-
expected: false, // seq=4 > 3
217-
},
218-
{
219-
name: "last event",
220-
cutoff: 3,
221-
eventType: serverDescriptionChangedEvent,
222-
index: 4,
223-
expected: false, // seq=5 > 3
224-
},
225-
}
226-
227-
for _, tt := range tests {
228-
t.Run(tt.name, func(t *testing.T) {
229-
es.cutoff.Store(tt.cutoff)
230-
result := es.shouldFilter(tt.eventType, tt.index)
231-
assert.Equal(t, tt.expected, result, "shouldFilter result mismatch")
232-
})
233-
}
234-
}

0 commit comments

Comments
 (0)