1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build batchtest
// +build batchtest
package raft
func init() {
userSnapshotErrorsOnNoData = false
}
// ApplyBatch enables MockFSM to satisfy the BatchingFSM interface. This
// function is gated by the batchtest build flag.
//
// NOTE: This is exposed for middleware testing purposes and is not a stable API
func (m *MockFSM) ApplyBatch(logs []*Log) []interface{} {
m.Lock()
defer m.Unlock()
ret := make([]interface{}, len(logs))
for i, log := range logs {
switch log.Type {
case LogCommand:
m.logs = append(m.logs, log.Data)
ret[i] = len(m.logs)
default:
ret[i] = nil
}
}
return ret
}
|