v1.5.1 增强程序稳定性

This commit is contained in:
robin
2026-03-22 17:37:40 +08:00
parent afbaaa869c
commit 17e182b413
652 changed files with 22949 additions and 34397 deletions

View File

@@ -0,0 +1,27 @@
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)
}
}