feat: import services and standardize Go 1.26.5
This commit is contained in:
87
apps/ec/order/test/rpc/cart_test.go
Normal file
87
apps/ec/order/test/rpc/cart_test.go
Normal file
@@ -0,0 +1,87 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "git.apinb.com/bsm-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)
|
||||
}
|
||||
Reference in New Issue
Block a user