memos/store/db/mysql/space_test.go
amblued fc7970a2d1 fix(spaces): add context to summary query errors
Preserve the underlying database error across all drivers and cover the wrapping behavior with focused tests. Make creation tests wait for the asynchronous completion callbacks to avoid timing-dependent assertions.
2026-08-26 22:47:54 +08:00

26 lines
548 B
Go

package mysql
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
"github.com/usememos/memos/store"
)
type failingMySQLSpaceSummaryRow struct {
err error
}
func (row failingMySQLSpaceSummaryRow) Scan(...any) error {
return row.err
}
func TestScanMySQLSpaceSummaryWrapsErrors(t *testing.T) {
cause := errors.New("scan failed")
err := scanMySQLSpaceSummary(failingMySQLSpaceSummaryRow{err: cause}, &store.Space{})
require.ErrorIs(t, err, cause)
require.ErrorContains(t, err, "failed to populate MySQL space summary")
}