Files
full/apps/ec/delivery/test/rpc/car_test.go

113 lines
2.4 KiB
Go

//go:build integration
package rpc
import (
"encoding/json"
"fmt"
"testing"
pb "git.apinb.com/bsm-service-ec/delivery/external/pb/delivery"
)
func TestCarAdd(t *testing.T) {
conn, ctx := GetCoon()
client := pb.NewCarClient(conn)
defer conn.Close()
data := pb.CarItem{
Brand: "比亚迪",
Version: "A6",
LicenseNumber: "川G782672",
TeamIdentity: "f3b9bf81-c721-4d1e-9261-2b96d0fe0cc5",
Contacts: "小黑",
Phone: "18725312289",
Picture: "https://www.baidu.com/x.png",
}
re, _ := json.Marshal(&data)
fmt.Printf("发送的测试消息: %s\n", re)
res, err := client.CarAdd(ctx, &data)
if err != nil {
panic(err)
}
s, err := json.Marshal(res)
if err != nil {
panic(err)
}
fmt.Printf("返回的测试消息: %s", s)
}
func TestCarSet(t *testing.T) {
conn, ctx := GetCoon()
client := pb.NewCarClient(conn)
defer conn.Close()
data := pb.CarItem{
Identity: "f747cf0a-5cb4-4969-a0fd-e7e5c73ee844",
Brand: "奥迪4",
Version: "A6",
LicenseNumber: "川G782671",
TeamIdentity: "f3b9bf81-c721-4d1e-9261-2b96d0fe0cc5",
Contacts: "小库",
Phone: "18725312289",
Picture: "https://www.baidu.com/x.png",
}
re, _ := json.Marshal(&data)
fmt.Printf("发送的测试消息: %s\n", re)
res, err := client.CarSet(ctx, &data)
if err != nil {
panic(err)
}
s, err := json.Marshal(res)
if err != nil {
panic(err)
}
fmt.Printf("返回的测试消息: %s", s)
}
func TestCarGet(t *testing.T) {
conn, ctx := GetCoon()
client := pb.NewCarClient(conn)
defer conn.Close()
data := pb.IdentRequest{
Identity: "e3a161fb-fdf1-481a-9c43-25020f5c271a",
}
re, _ := json.Marshal(&data)
fmt.Printf("发送的测试消息: %s\n", re)
res, err := client.CarGet(ctx, &data)
if err != nil {
panic(err)
}
s, err := json.Marshal(res)
if err != nil {
panic(err)
}
fmt.Printf("返回的测试消息: %s", s)
}
func TestCarList(t *testing.T) {
conn, ctx := GetCoon()
client := pb.NewCarClient(conn)
defer conn.Close()
data := pb.FetchRequest{
PageNo: 1,
PageSize: 10,
Params: map[string]string{
"identity": "",
"team_identity": "",
"license_number": "川G",
"status": "",
},
}
re, _ := json.Marshal(&data)
fmt.Printf("发送的测试消息: %s\n", re)
res, err := client.CarList(ctx, &data)
if err != nil {
panic(err)
}
s, err := json.Marshal(res)
if err != nil {
panic(err)
}
fmt.Printf("返回的测试消息: %s", s)
}