2019-11-23 02:37:13 -05:00
|
|
|
package serializer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCheckSettingValue(t *testing.T) {
|
|
|
|
asserts := assert.New(t)
|
|
|
|
|
|
|
|
asserts.Equal("", checkSettingValue(map[string]string{}, "key"))
|
|
|
|
asserts.Equal("123", checkSettingValue(map[string]string{"key": "123"}, "key"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildSiteConfig(t *testing.T) {
|
|
|
|
asserts := assert.New(t)
|
|
|
|
|
2019-11-25 01:08:11 -05:00
|
|
|
res := BuildSiteConfig(map[string]string{"not exist": ""}, nil)
|
2019-11-23 02:37:13 -05:00
|
|
|
asserts.Equal("", res.Data.(SiteConfig).SiteName)
|
|
|
|
|
2019-11-25 01:08:11 -05:00
|
|
|
res = BuildSiteConfig(map[string]string{"siteName": "123"}, nil)
|
2019-11-23 02:37:13 -05:00
|
|
|
asserts.Equal("123", res.Data.(SiteConfig).SiteName)
|
|
|
|
|
2019-11-25 01:08:11 -05:00
|
|
|
res = BuildSiteConfig(map[string]string{"qq_login": "1"}, nil)
|
2019-11-23 02:37:13 -05:00
|
|
|
asserts.Equal(true, res.Data.(SiteConfig).QQLogin)
|
|
|
|
}
|