2021-02-28 10:58:04 -05:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-03-18 11:13:22 -04:00
|
|
|
"github.com/naiba/nezha/pkg/utils"
|
2021-02-28 10:58:04 -05:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestServerMarshal(t *testing.T) {
|
|
|
|
patterns := []string{
|
|
|
|
"asd > asd",
|
|
|
|
"asd \" asd",
|
|
|
|
"asd } asd",
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < len(patterns); i++ {
|
|
|
|
server := Server{
|
|
|
|
Name: patterns[i],
|
|
|
|
Tag: patterns[i],
|
|
|
|
}
|
|
|
|
serverStr := string(server.Marshal())
|
|
|
|
var serverRestore Server
|
2022-03-18 11:13:22 -04:00
|
|
|
assert.Nil(t, utils.Json.Unmarshal([]byte(serverStr), &serverRestore))
|
2021-02-28 10:58:04 -05:00
|
|
|
assert.Equal(t, server, serverRestore)
|
|
|
|
}
|
|
|
|
}
|