fix: 多件档口入库码逐件回写 (#250)
This commit is contained in:
@@ -569,8 +569,8 @@ func TestClient_DetailListByStock_超过100个id报错(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_InnerCodeWrite_聚合码参数和路径正确且只发送一次(t *testing.T) {
|
||||
targetCode := "DK260815A160101,DK260815A160102"
|
||||
func TestClient_InnerCodeWrite_单件码参数和路径正确且只发送一次(t *testing.T) {
|
||||
targetCode := "DK260815A160101"
|
||||
var requests atomic.Int32
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
requests.Add(1)
|
||||
@@ -582,7 +582,7 @@ func TestClient_InnerCodeWrite_聚合码参数和路径正确且只发送一次(
|
||||
}
|
||||
case "/am/stock/detail/updateDetailCode":
|
||||
query := r.URL.Query()
|
||||
if query.Get("t") != "0" || query.Get("id") != "11" || query.Get("detailId") != "22" || query.Get("code") != targetCode {
|
||||
if r.Method != http.MethodPost || query.Get("t") == "" || query.Get("id") != "11" || query.Get("detailId") != "22" || query.Get("code") != targetCode {
|
||||
t.Errorf("update query=%v", query)
|
||||
}
|
||||
default:
|
||||
@@ -606,6 +606,28 @@ func TestClient_InnerCodeWrite_聚合码参数和路径正确且只发送一次(
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_CreateInnerCodeDetail_使用零价单件请求并返回ID(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost || r.URL.Path != "/am/stock/detail/createDetail" {
|
||||
t.Fatalf("request=%s %s", r.Method, r.URL.Path)
|
||||
}
|
||||
var body map[string]any
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["stockId"] != float64(11) || body["productQty"] != float64(1) || body["productPrice"] != float64(0) || body["productTitle"] != "档口第2件-IC1" {
|
||||
t.Fatalf("body=%v", body)
|
||||
}
|
||||
io.WriteString(w, `{"status":true,"msg":"创建成功","data":147372531,"code":null}`)
|
||||
}))
|
||||
defer server.Close()
|
||||
client, _ := New(server.URL)
|
||||
detailID, err := client.CreateInnerCodeDetail(context.Background(), 11, "档口第2件-IC1")
|
||||
if err != nil || detailID != 147372531 {
|
||||
t.Fatalf("detailID=%d err=%v", detailID, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_InnerCodeWrite_未知结果与明确业务失败分开(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user