Files
waf-platform/EdgeNode/internal/utils/kvstore/tx_internal_test.go
2026-03-22 17:37:40 +08:00

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)
}
}