feat(t237): import freight orders synchronously
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"cmroubao/backend-api/internal/domain"
|
||||
"cmroubao/backend-api/internal/usecase"
|
||||
)
|
||||
|
||||
func TestMapFreightPreflightErrorUsesStablePublicErrors(t *testing.T) {
|
||||
@@ -14,6 +15,8 @@ func TestMapFreightPreflightErrorUsesStablePublicErrors(t *testing.T) {
|
||||
}{
|
||||
{domain.ErrFreightSourceOCRInvalid, ErrOCRServiceInvalid},
|
||||
{domain.ErrFreightSourceNotConfigured, ErrERPNotConfigured},
|
||||
{domain.ErrFreightSourceSessionNeeded, ErrERPSessionNeeded},
|
||||
{domain.ErrFreightSourceNotFound, ErrERPFreightNotFound},
|
||||
{domain.ErrFreightSourceLoginRejected, ErrERPLoginRejected},
|
||||
{domain.ErrFreightSourceProtocol, ErrERPProtocol},
|
||||
{domain.ErrFreightSourceUnavailable, ErrERPUnavailable},
|
||||
@@ -33,6 +36,8 @@ func TestMapFreightCreateErrorPreservesPreflightErrors(t *testing.T) {
|
||||
}{
|
||||
{domain.ErrFreightSourceOCRInvalid, ErrOCRServiceInvalid},
|
||||
{domain.ErrFreightSourceNotConfigured, ErrERPNotConfigured},
|
||||
{domain.ErrFreightSourceSessionNeeded, ErrERPSessionNeeded},
|
||||
{domain.ErrFreightSourceNotFound, ErrERPFreightNotFound},
|
||||
{domain.ErrFreightSourceLoginRejected, ErrERPLoginRejected},
|
||||
{domain.ErrFreightSourceProtocol, ErrERPProtocol},
|
||||
{domain.ErrFreightSourceUnavailable, ErrERPUnavailable},
|
||||
@@ -43,3 +48,23 @@ func TestMapFreightCreateErrorPreservesPreflightErrors(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMapFreightCreateErrorUsesStableSyncErrors(t *testing.T) {
|
||||
for _, testCase := range []struct {
|
||||
code string
|
||||
want error
|
||||
}{
|
||||
{"FREIGHT_SYNC_BUSY", ErrFreightSyncBusy},
|
||||
{"FREIGHT_SYNC_TIMEOUT", ErrFreightSyncTimeout},
|
||||
} {
|
||||
source := &usecase.Error{
|
||||
Kind: usecase.ErrorKindUnavailable,
|
||||
Code: testCase.code,
|
||||
Fields: map[string]string{},
|
||||
}
|
||||
actual := mapFreightCreateError(source)
|
||||
if !errors.Is(actual, testCase.want) || !errors.Is(actual, source) {
|
||||
t.Fatalf("mapFreightCreateError(%s) = %v", testCase.code, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user