fix: ext issues
This commit is contained in:
46
main_test.go
46
main_test.go
@@ -1,7 +1,10 @@
|
||||
package main
|
||||
|
||||
// v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
import (
|
||||
"context"
|
||||
"mime"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"exporter/database/telegram_resource/public/table"
|
||||
@@ -9,6 +12,10 @@ import (
|
||||
"github.com/dustin/go-humanize"
|
||||
. "github.com/go-jet/jet/v2/postgres"
|
||||
"github.com/spf13/viper"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func Test_Mime(t *testing.T) {
|
||||
@@ -45,3 +52,42 @@ func Test_Sql(t *testing.T) {
|
||||
)
|
||||
t.Log(stmt.DebugSql())
|
||||
}
|
||||
|
||||
func Test_PublishGrpc(t *testing.T) {
|
||||
token := "eyJhbGciOiJIUzI1NiIsImtpZCI6InYxIiwidHlwIjoiSldUIn0.eyJuYW1lIjoicm9nZWVjbiIsImlzcyI6Im1lbW9zIiwic3ViIjoiMSIsImF1ZCI6WyJ1c2VyLmFjY2Vzcy10b2tlbiJdLCJpYXQiOjE3MjU2MTA2NzF9.PdF-eH0eSkaLFDl242To57AWkvv71oY57PMysx-nS24"
|
||||
// new Grpc Client
|
||||
ctx := context.Background()
|
||||
target := "10.1.1.3:5230"
|
||||
conn, err := grpc.NewClient(
|
||||
target,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
ctx = metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{
|
||||
"Authorization": "Bearer " + token,
|
||||
}))
|
||||
|
||||
memoSvc := v1pb.NewMemoServiceClient(conn)
|
||||
memos, err := memoSvc.ListMemos(ctx, &v1pb.ListMemosRequest{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, memo := range memos.Memos {
|
||||
t.Log(memo.Content)
|
||||
t.Log("--------------------")
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Ext(t *testing.T) {
|
||||
name := "abc.jpg"
|
||||
ext := filepath.Ext(name)
|
||||
t.Logf("Name: %s, Ext: %s", name, ext)
|
||||
|
||||
name = "abc_jpg"
|
||||
ext = filepath.Ext(name)
|
||||
t.Logf("Name: %s, Ext: %s", name, ext)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user