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

35 lines
801 B
Go
Raw Normal View History

2021-06-30 19:59:49 +08:00
package models
2021-06-27 21:59:37 +08:00
import (
_ "github.com/go-sql-driver/mysql"
_ "github.com/iwind/TeaGo/bootstrap"
2021-12-03 12:06:13 +08:00
"github.com/iwind/TeaGo/dbs"
2021-08-30 15:23:51 +08:00
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
2021-09-08 17:32:08 +08:00
timeutil "github.com/iwind/TeaGo/utils/time"
"testing"
2021-06-27 21:59:37 +08:00
)
func TestNewMetricStatDAO_InsertMany(t *testing.T) {
2021-12-03 12:06:13 +08:00
for i := 0; i <= 1; i++ {
2021-09-08 17:32:08 +08:00
err := NewMetricStatDAO().CreateStat(nil, types.String(i)+"_v1", 18, int64(rands.Int(0, 10000)), int64(rands.Int(0, 10000)), int64(rands.Int(0, 100)), []string{"/html" + types.String(i)}, 1, timeutil.Format("Ymd"), 0)
if err != nil {
t.Fatal(err)
}
2021-12-03 12:06:13 +08:00
if i%10000 == 0 {
2021-08-30 15:23:51 +08:00
t.Log(i)
}
}
t.Log("done")
}
2021-12-03 12:06:13 +08:00
func TestMetricStatDAO_Clean(t *testing.T) {
dbs.NotifyReady()
err := NewMetricStatDAO().Clean(nil)
if err != nil {
t.Fatal(err)
}
t.Log("ok")
}