fix(t231): expose freight preflight errors

This commit is contained in:
QiuSW
2026-07-29 10:58:28 +08:00
parent 2d8ad97167
commit 5ed27afeb5
15 changed files with 240 additions and 56 deletions
@@ -0,0 +1,27 @@
package webui
import (
"errors"
"testing"
"cmroubao/backend-api/internal/domain"
)
func TestMapFreightPreflightErrorUsesStablePublicErrors(t *testing.T) {
testCases := []struct {
err error
want error
}{
{domain.ErrFreightSourceOCRInvalid, ErrOCRServiceInvalid},
{domain.ErrFreightSourceNotConfigured, ErrERPNotConfigured},
{domain.ErrFreightSourceLoginRejected, ErrERPLoginRejected},
{domain.ErrFreightSourceProtocol, ErrERPProtocol},
{domain.ErrFreightSourceUnavailable, ErrERPUnavailable},
}
for _, testCase := range testCases {
actual := mapFreightPreflightError(testCase.err)
if !errors.Is(actual, testCase.want) || !errors.Is(actual, testCase.err) {
t.Fatalf("mapFreightPreflightError(%v) = %v", testCase.err, actual)
}
}
}