Files
EdgeAPI/internal/db/models/sys_setting_dao_test.go

51 lines
1.0 KiB
Go
Raw Normal View History

2020-09-26 08:06:40 +08:00
package models
import (
2024-07-27 14:15:25 +08:00
"testing"
2020-09-26 08:06:40 +08:00
_ "github.com/go-sql-driver/mysql"
2021-01-10 17:34:35 +08:00
"github.com/iwind/TeaGo/dbs"
2020-09-26 08:06:40 +08:00
)
func TestSysSettingDAO_UpdateSetting(t *testing.T) {
2021-01-10 17:34:35 +08:00
var tx *dbs.Tx
err := NewSysSettingDAO().UpdateSetting(tx, "hello", []byte(`"world"`))
2020-09-26 08:06:40 +08:00
if err != nil {
t.Fatal(err)
}
2021-01-10 17:34:35 +08:00
value, err := NewSysSettingDAO().ReadSetting(tx, "hello")
2020-09-26 08:06:40 +08:00
if err != nil {
t.Fatal(err)
}
t.Log("value:", string(value))
}
func TestSysSettingDAO_UpdateSetting_Args(t *testing.T) {
2021-01-10 17:34:35 +08:00
var tx *dbs.Tx
err := NewSysSettingDAO().UpdateSetting(tx, "hello %d", []byte(`"world 123"`), 123)
2020-09-26 08:06:40 +08:00
if err != nil {
t.Fatal(err)
}
2021-01-10 17:34:35 +08:00
value, err := NewSysSettingDAO().ReadSetting(tx, "hello %d", 123)
2020-09-26 08:06:40 +08:00
if err != nil {
t.Fatal(err)
}
t.Log("value:", string(value))
}
func TestSysSettingDAO_CompareInt64Setting(t *testing.T) {
2021-01-10 17:34:35 +08:00
var tx *dbs.Tx
i, err := NewSysSettingDAO().CompareInt64Setting(tx, "int64", 1024)
if err != nil {
t.Fatal(err)
}
t.Log("result:", i)
}
func TestSysSettingDAO_ReadProductName(t *testing.T) {
var tx *dbs.Tx
t.Log(NewSysSettingDAO().ReadProductName(tx))
}