1.4.5.2
This commit is contained in:
46
EdgePlus/pkg/utils/encoder_test.go
Normal file
46
EdgePlus/pkg/utils/encoder_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEncodeMap(t *testing.T) {
|
||||
{
|
||||
t.Log(Encode([]byte("123")))
|
||||
}
|
||||
{
|
||||
s, err := EncodeMap(maps.Map{"a": 1})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(s)
|
||||
|
||||
t.Log(Decode([]byte(s)))
|
||||
}
|
||||
}
|
||||
|
||||
func TestEncodeKey(t *testing.T) {
|
||||
var key = &Key{
|
||||
DayFrom: "2020-10-10",
|
||||
DayTo: "2022-10-10",
|
||||
MacAddresses: []string{"*"},
|
||||
Hostname: "web001",
|
||||
Company: "STILL",
|
||||
Nodes: 10,
|
||||
}
|
||||
encodedString, err := EncodeKey(key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("encoded:", encodedString)
|
||||
|
||||
key, err = DecodeKey([]byte(encodedString))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
logs.PrintAsJSON(key, t)
|
||||
}
|
||||
Reference in New Issue
Block a user