28 lines
550 B
Go
28 lines
550 B
Go
package kvstore
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/cockroachdb/pebble"
|
|
)
|
|
|
|
func TestTx_commit_StringPanicReturnsError(t *testing.T) {
|
|
oldCommitBatch := commitBatch
|
|
commitBatch = func(batch *pebble.Batch, opt *pebble.WriteOptions) error {
|
|
panic("boom")
|
|
}
|
|
defer func() {
|
|
commitBatch = oldCommitBatch
|
|
}()
|
|
|
|
tx := &Tx[string]{}
|
|
err := tx.commit(DefaultWriteOptions)
|
|
if err == nil {
|
|
t.Fatal("expected error, got nil")
|
|
}
|
|
if !strings.Contains(err.Error(), "commit batch failed: boom") {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
}
|