34 lines
701 B
Go
34 lines
701 B
Go
// 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)
|
|
}
|