feat(t227): query ERP directly from Go
This commit is contained in:
@@ -672,7 +672,7 @@ func daysInclusive(start, end time.Time) int {
|
||||
func freightSourceErrorCode(err error) string {
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrFreightSourceNotConfigured):
|
||||
return "ERP_CONNECTOR_NOT_CONFIGURED"
|
||||
return "ERP_NOT_CONFIGURED"
|
||||
case errors.Is(err, domain.ErrFreightSourceSessionNeeded):
|
||||
return "ERP_SESSION_REQUIRED"
|
||||
case errors.Is(err, domain.ErrFreightSourceNotFound):
|
||||
@@ -680,7 +680,7 @@ func freightSourceErrorCode(err error) string {
|
||||
case errors.Is(err, domain.ErrFreightSourceProtocol):
|
||||
return "ERP_RESPONSE_INVALID"
|
||||
default:
|
||||
return "ERP_CONNECTOR_UNAVAILABLE"
|
||||
return "ERP_UNAVAILABLE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,24 @@ func TestFreightNormalizationRejectsConflictingIdentityAndInvalidTime(
|
||||
}
|
||||
}
|
||||
|
||||
func TestFreightSourceErrorCodesAreSourceNeutral(t *testing.T) {
|
||||
cases := []struct {
|
||||
err error
|
||||
want string
|
||||
}{
|
||||
{domain.ErrFreightSourceNotConfigured, "ERP_NOT_CONFIGURED"},
|
||||
{domain.ErrFreightSourceSessionNeeded, "ERP_SESSION_REQUIRED"},
|
||||
{domain.ErrFreightSourceNotFound, "ERP_FREIGHT_NOT_FOUND"},
|
||||
{domain.ErrFreightSourceProtocol, "ERP_RESPONSE_INVALID"},
|
||||
{errors.New("temporary source failure"), "ERP_UNAVAILABLE"},
|
||||
}
|
||||
for _, testCase := range cases {
|
||||
if got := freightSourceErrorCode(testCase.err); got != testCase.want {
|
||||
t.Fatalf("freightSourceErrorCode(%v) = %q, want %q", testCase.err, got, testCase.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFreightDateQuerySplitsIntoSevenDayWindows(t *testing.T) {
|
||||
source := &recordingDateSource{}
|
||||
service := &FreightService{source: source}
|
||||
|
||||
Reference in New Issue
Block a user