1.4.5.2
This commit is contained in:
33
EdgeNode/internal/uam/key_test.go
Normal file
33
EdgeNode/internal/uam/key_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build plus
|
||||
|
||||
package uam_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/uam"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKey_AsPB(t *testing.T) {
|
||||
var key = &uam.Key{
|
||||
Timestamp: fasttime.Now().Unix(),
|
||||
Hash: 123456,
|
||||
Host: "example.com",
|
||||
}
|
||||
pbData, err := key.AsPB()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
t.Log("["+types.String(len(pbData))+"]", pbData)
|
||||
|
||||
var key2 = &uam.Key{}
|
||||
err = proto.Unmarshal(pbData, key2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(key2)
|
||||
}
|
||||
Reference in New Issue
Block a user