19 lines
428 B
Go
19 lines
428 B
Go
package tianyuanapi
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestMapBusinessError(t *testing.T) {
|
|
if err := mapBusinessError(0, ""); err != nil {
|
|
t.Fatalf("code 0 should be nil, got %v", err)
|
|
}
|
|
if !errors.Is(mapBusinessError(1000, "查无"), ErrNotFound) {
|
|
t.Fatal("expected ErrNotFound for 1000")
|
|
}
|
|
if !errors.Is(mapBusinessError(2001, "业务失败"), ErrDatasource) {
|
|
t.Fatal("expected ErrDatasource for 2001")
|
|
}
|
|
}
|