refactor: reorganize modules and add Linux build tooling
This commit is contained in:
44
module/base/sender/test/grpc/sms_test.go
Normal file
44
module/base/sender/test/grpc/sms_test.go
Normal file
@@ -0,0 +1,44 @@
|
||||
//go:build integration
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
pb "bsm/full/module/base/sender/pb"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
func TestSms(t *testing.T) {
|
||||
conn, err := grpc.NewClient("192.168.31.148:12208",
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
log.Fatalf("连接失败: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
client := pb.NewSmsClient(conn)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
req := &pb.SmsSendRequest{
|
||||
Phone: "18610192292",
|
||||
TemplateCode: "SMS_101025114",
|
||||
Paramters: map[string]string{
|
||||
"code": "123456",
|
||||
},
|
||||
SignName: "身份验证",
|
||||
Provider: "aliyun",
|
||||
}
|
||||
res, err := client.Send(ctx, req)
|
||||
if err != nil {
|
||||
log.Fatalf("RPC调用失败: %v", err)
|
||||
}
|
||||
|
||||
log.Printf("响应结果: %v", res.GetReply())
|
||||
}
|
||||
Reference in New Issue
Block a user