refactor: reorganize modules and add Linux build tooling
This commit is contained in:
27
module/ec/delivery/test/rpc/basic.go
Normal file
27
module/ec/delivery/test/rpc/basic.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"git.apinb.com/bsm-sdk/engine/utils"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var url = "127.0.0.1:12264"
|
||||
|
||||
var token = os.Getenv("BSM_DELIVERY_TOKEN")
|
||||
|
||||
func GetCoon() (*grpc.ClientConn, context.Context) {
|
||||
md := metadata.New(map[string]string{"request_id": utils.ULID(), "workspace": "scf"})
|
||||
md.Append("authorization", token)
|
||||
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||
// 建立GRPC连接
|
||||
conn, err := grpc.Dial(url, grpc.WithInsecure())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return conn, ctx
|
||||
}
|
||||
112
module/ec/delivery/test/rpc/car_test.go
Normal file
112
module/ec/delivery/test/rpc/car_test.go
Normal file
@@ -0,0 +1,112 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/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)
|
||||
}
|
||||
107
module/ec/delivery/test/rpc/member_test.go
Normal file
107
module/ec/delivery/test/rpc/member_test.go
Normal file
@@ -0,0 +1,107 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/ec/delivery/external/pb/delivery"
|
||||
)
|
||||
|
||||
func TestMemberAdd(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewMemberClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.MemberItem{
|
||||
TeamIdentity: "f3b9bf81-c721-4d1e-9261-2b96d0fe0cc5",
|
||||
Name: "小秦",
|
||||
Phone: "18725312289",
|
||||
Picture: "https://www.baidu.com/x.png",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.MemberAdd(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestMemberSet(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewMemberClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.MemberItem{
|
||||
Identity: "1e280531-8ffd-4cf8-b445-f37ce1807685",
|
||||
TeamIdentity: "f3b9bf81-c721-4d1e-9261-2b96d0fe0cc5",
|
||||
Name: "小秦",
|
||||
Phone: "18725312289",
|
||||
Picture: "https://www.baidu.com/xx.png",
|
||||
Status: 1,
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.MemberSet(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestMemberGet(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewMemberClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.IdentRequest{
|
||||
Identity: "1e280531-8ffd-4cf8-b445-f37ce1807685",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.MemberGet(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestMemberList(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewMemberClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.FetchRequest{
|
||||
PageNo: 1,
|
||||
PageSize: 10,
|
||||
Params: map[string]string{
|
||||
"identity": "",
|
||||
"team_identity": "",
|
||||
"name": "秦",
|
||||
"status": "",
|
||||
},
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.MemberList(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
109
module/ec/delivery/test/rpc/team_test.go
Normal file
109
module/ec/delivery/test/rpc/team_test.go
Normal file
@@ -0,0 +1,109 @@
|
||||
//go:build integration
|
||||
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
pb "bsm/full/module/ec/delivery/external/pb/delivery"
|
||||
)
|
||||
|
||||
func TestTeamAdd(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewTeamClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.TeamItem{
|
||||
Title: "XX专送团队",
|
||||
Owner: "B9355263-4983-5BAA-631A-046B453480C8",
|
||||
Contacts: "老王",
|
||||
Phone: "13402984328",
|
||||
Logo: "http://www.baidu.com/sad.jpg",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.TeamAdd(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestTeamSet(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewTeamClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.TeamItem{
|
||||
Title: "XX专送团队",
|
||||
Owner: "B9355263-4983-5BAA-631A-046B453480C8",
|
||||
Contacts: "老李",
|
||||
Phone: "13402984328",
|
||||
Logo: "http://www.baidu.com/sad.jpg",
|
||||
Identity: "f3b9bf81-c721-4d1e-9261-2b96d0fe0cc5",
|
||||
Status: 1,
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.TeamSet(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestTeamGet(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewTeamClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.IdentRequest{
|
||||
Identity: "f3b9bf81-c721-4d1e-9261-2b96d0fe0cc5",
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.TeamGet(ctx, &data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("返回的测试消息: %s", s)
|
||||
}
|
||||
func TestTeamList(t *testing.T) {
|
||||
conn, ctx := GetCoon()
|
||||
client := pb.NewTeamClient(conn)
|
||||
|
||||
defer conn.Close()
|
||||
data := pb.FetchRequest{
|
||||
PageNo: 1,
|
||||
PageSize: 10,
|
||||
Params: map[string]string{
|
||||
"identity": "",
|
||||
"title": "",
|
||||
"owner": "",
|
||||
"status": "",
|
||||
},
|
||||
}
|
||||
re, _ := json.Marshal(&data)
|
||||
fmt.Printf("发送的测试消息: %s\n", re)
|
||||
res, err := client.TeamList(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