refactor: reorganize modules and add Linux build tooling
This commit is contained in:
28
module/ec/order/test/rpc/bisic_test.go
Normal file
28
module/ec/order/test/rpc/bisic_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var url = "127.0.0.1:12442"
|
||||
|
||||
var token = os.Getenv("BSM_ORDER_TOKEN")
|
||||
|
||||
func GetCoon() (*grpc.ClientConn, context.Context) {
|
||||
md := metadata.New(map[string]string{"request_id": utils.UUID(), "workspace": "scf"})
|
||||
md.Append("authorization", token)
|
||||
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||
// 建立GRPC连接
|
||||
conn, err := grpc.NewClient(url, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return conn, ctx
|
||||
}
|
||||
87
module/ec/order/test/rpc/cart_test.go
Normal file
87
module/ec/order/test/rpc/cart_test.go
Normal file
@@ -0,0 +1,87 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
)
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewCartClient(coon)
|
||||
defer coon.Close()
|
||||
res, err := clent.Create(ctx, &pb.CartAddRequest{
|
||||
CartIdentity: "10b8b3a0-9679-17d0-bb86-0ef402f390d6",
|
||||
PassportIdentity: "cwG76v3OIadIvTqTmAM49",
|
||||
ProductId: 3,
|
||||
ProductArgs: "",
|
||||
Number: 2,
|
||||
ProductIdentity: "5ad0134f-691b-46c6-9b6f-d067607f769d",
|
||||
SpecId: 12,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
|
||||
func TestSet(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
clent := pb.NewCartClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.CartSetRequest{
|
||||
Identity: "dc4983f1-f44f-4727-acda-874365ac186a",
|
||||
Number: 12,
|
||||
// UnitPrice: 1,
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := clent.Modify(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
clent := pb.NewCartClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.CartGetRequest{
|
||||
//CartIdentity: "10b8b3a0-9679-17d0-bb86-0ef402f390d6",
|
||||
PassportIdentity: "cwG76v3OIadIvTqTmAM49",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := clent.Fetch(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestDel(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewCartClient(coon)
|
||||
defer coon.Close()
|
||||
res, err := clent.Delete(ctx, &pb.CartDelRequest{
|
||||
Id: []int64{1},
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
23
module/ec/order/test/rpc/coupon_test.go
Normal file
23
module/ec/order/test/rpc/coupon_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
)
|
||||
|
||||
func TestByStatus(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewCouponClient(coon)
|
||||
defer coon.Close()
|
||||
res, err := clent.ByStatus(ctx, &pb.Status{
|
||||
Status: 1,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
30
module/ec/order/test/rpc/mgt_test.go
Normal file
30
module/ec/order/test/rpc/mgt_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
)
|
||||
|
||||
func TestOrderListByStore(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewMgtClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.OrderListByStoreRequest{
|
||||
PageNo: 1,
|
||||
PageSize: 5,
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.OrderListByStore(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, _ := json.Marshal(res)
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
23
module/ec/order/test/rpc/rpc.go
Normal file
23
module/ec/order/test/rpc/rpc.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package rpc
|
||||
|
||||
/*
|
||||
func main() {
|
||||
md := metadata.New(map[string]string{"request_id": utils.UUID(), "workspace": "scf"})
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||
|
||||
// 建立GRPC连接
|
||||
conn, err := grpc.Dial("127.0.0.1:12201", grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
c := pb.NewCheckClient(conn)
|
||||
r, err := c.Hello(ctx, &pb.Crc{
|
||||
Code: "david",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的消息: %s", r.Message)
|
||||
}
|
||||
*/
|
||||
189
module/ec/order/test/rpc/summary_test.go
Normal file
189
module/ec/order/test/rpc/summary_test.go
Normal file
@@ -0,0 +1,189 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
)
|
||||
|
||||
func TestQuickCreateByToken(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewSummaryClient(coon)
|
||||
defer coon.Close()
|
||||
|
||||
data := pb.QuickCreateByProductRequest{
|
||||
PartnerId: 5,
|
||||
ProductIdentity: "a34d83f3-f09c-42e8-8c2c-85d5eba363c3",
|
||||
Number: 10,
|
||||
SpecIdentity: "ca0a6439-7e8f-4203-8e13-b29529222b1b",
|
||||
StoreIdentity: "B9355263-4983-5BAA-631A-046B453480C8",
|
||||
AddressIdentity: "c01a1c75-5b5b-460f-9335-858029e9617f",
|
||||
DeliveryTime: "2024-06-27 00:00:00",
|
||||
MemberIdentity: "1e280531-8ffd-4cf8-b445-f37ce1807685",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := clent.QuickCreateByProduct(ctx, &data)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
|
||||
func TestSubmit(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewSummaryClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.SubmitRequest{
|
||||
Id: []string{"68ed35da-2ed8-458b-8669-07ade375e8cf"},
|
||||
PartnerId: 5,
|
||||
StoreIdentity: "B9355263-4983-5BAA-631A-046B453480C8",
|
||||
AddressIdentity: "b5d9173d-847d-417d-946e-750db94ca3b6",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.Submit(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestCheck(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewSummaryClient(coon)
|
||||
defer coon.Close()
|
||||
res, err := clent.Check(ctx, &pb.Empty{})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
func TestGetDetail(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
client := pb.NewSummaryClient(coon)
|
||||
defer coon.Close()
|
||||
data := pb.IdentRequest{
|
||||
Identity: "78d9d2e9-8c63-4ff4-a6ee-4b2234944fcb",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.Get(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
|
||||
func TestSummaryList(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
client := pb.NewSummaryClient(coon)
|
||||
defer coon.Close()
|
||||
// Unpaid:未付款
|
||||
// Paid:已付款
|
||||
// NotDelivered:未发货
|
||||
// Delivered:已发货
|
||||
// NotComment:待评论
|
||||
data := pb.SummaryListRequest{
|
||||
// Type: "Paid",
|
||||
OrderStatus: 2,
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.List(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestConfirm(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewSummaryClient(coon)
|
||||
defer coon.Close()
|
||||
res, err := clent.Confirm(ctx, &pb.ConfirmRequest{
|
||||
OrderNo: "2437105418797837",
|
||||
AddressIdentity: "10",
|
||||
CouponIdentity: "c3d9af1d-d26d-c313-a5df-091ad8d2acf8",
|
||||
Remark: "测试信息",
|
||||
LogisticsFee: 4,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
func TestCancel(t *testing.T) {
|
||||
coon, ctx := GetCoon()
|
||||
clent := pb.NewSummaryClient(coon)
|
||||
defer coon.Close()
|
||||
res, err := clent.Cancel(ctx, &pb.CancelRequest{
|
||||
OrderNo: "2437105418797837",
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", res)
|
||||
}
|
||||
func TestQuickCreateByProduct(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewSummaryClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.QuickCreateByProductRequest{
|
||||
PartnerId: 5,
|
||||
StoreIdentity: "B9355263-4983-5BAA-631A-046B453480C8",
|
||||
ProductIdentity: "a34d83f3-f09c-42e8-8c2c-85d5eba363c3",
|
||||
Number: 2,
|
||||
Args: "{\"id\":\"11\",\"identity\":\"bd6b0d21-97d9-4b48-80d1-df28d02b444c\",\"product_id\":\"a8ec80f3-7934-4558-912e-31b4bda9428d\",\"title\":\"瓶数02\",\"stock_type\":2,\"stock\":\"0\",\"price\":\"11300\",\"direct_sales\":\"0\",\"tp_type\":0,\"ds_tp_type\":0,\"img\":\"\",\"spec_no\":\"918946794533509425\"}",
|
||||
AddressIdentity: "c01a1c75-5b5b-460f-9335-858029e9617f",
|
||||
DeliveryTime: "",
|
||||
SpecIdentity: "ca0a6439-7e8f-4203-8e13-b29529222b1b",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.QuickCreateByProduct(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestSimulatePay(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewSummaryClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.SimulatePayRequest{
|
||||
Identity: []string{"d78e4521-1610-494c-a12e-20211301fa31"},
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.SimulatePay(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
Reference in New Issue
Block a user