sync: 同步 v1.0.4 开源代码并脱敏
This commit is contained in:
@@ -149,3 +149,22 @@ func resetRabbitMQState(t *testing.T) {
|
||||
connMu.Unlock()
|
||||
})
|
||||
}
|
||||
|
||||
func TestUnregisterConsumerPreservesShutdownSnapshot(t *testing.T) {
|
||||
consumerMu.Lock()
|
||||
original := consumers
|
||||
first, second, third := &managedConsumer{}, &managedConsumer{}, &managedConsumer{}
|
||||
consumers = []*managedConsumer{first, second, third}
|
||||
snapshot := consumers
|
||||
consumerMu.Unlock()
|
||||
defer func() { consumerMu.Lock(); consumers = original; consumerMu.Unlock() }()
|
||||
unregisterConsumer(second)
|
||||
consumerMu.Lock()
|
||||
defer consumerMu.Unlock()
|
||||
if len(consumers) != 2 || consumers[0] != first || consumers[1] != third {
|
||||
t.Fatal("consumer not removed")
|
||||
}
|
||||
if snapshot[1] != second || snapshot[2] != third {
|
||||
t.Fatal("shutdown snapshot mutated")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user