refactor: map 移除适配

This commit is contained in:
kercylan 2023-07-21 23:35:01 +08:00
parent d0d2087fee
commit d446ff18b9
2 changed files with 3 additions and 67 deletions

View File

@ -1,63 +0,0 @@
package cs_test
import (
"github.com/kercylan98/minotaur/planner/pce/cs"
. "github.com/smartystreets/goconvey/convey"
"github.com/tealeg/xlsx"
"testing"
)
func TestNewIndexXlsxConfig(t *testing.T) {
Convey("TestNewIndexXlsxConfig", t, func() {
f, err := xlsx.OpenFile("./xlsx_template.xlsx")
if err != nil {
panic(err)
}
config := cs.NewXlsx(f.Sheets[1])
So(config, ShouldNotBeNil)
})
}
func TestXlsxIndexConfig_GetConfigName(t *testing.T) {
Convey("TestXlsxIndexConfig_GetConfigName", t, func() {
f, err := xlsx.OpenFile("./xlsx_template.xlsx")
if err != nil {
panic(err)
}
config := cs.NewXlsx(f.Sheets[1])
So(config.GetConfigName(), ShouldEqual, "IndexConfig")
})
}
func TestXlsxIndexConfig_GetDisplayName(t *testing.T) {
Convey("TestXlsxIndexConfig_GetDisplayName", t, func() {
f, err := xlsx.OpenFile("./xlsx_template.xlsx")
if err != nil {
panic(err)
}
config := cs.NewXlsx(f.Sheets[1])
So(config.GetDisplayName(), ShouldEqual, "有索引")
})
}
func TestXlsxIndexConfig_GetDescription(t *testing.T) {
Convey("TestXlsxIndexConfig_GetDescription", t, func() {
f, err := xlsx.OpenFile("./xlsx_template.xlsx")
if err != nil {
panic(err)
}
config := cs.NewXlsx(f.Sheets[1])
So(config.GetDescription(), ShouldEqual, "暂无描述")
})
}
func TestXlsxIndexConfig_GetIndexCount(t *testing.T) {
Convey("TestXlsxIndexConfig_GetIndexCount", t, func() {
f, err := xlsx.OpenFile("./xlsx_template.xlsx")
if err != nil {
panic(err)
}
config := cs.NewXlsx(f.Sheets[1])
So(config.GetIndexCount(), ShouldEqual, 2)
})
}

View File

@ -1,8 +1,7 @@
package report
import (
"github.com/kercylan98/minotaur/utils/asynchronous"
"github.com/kercylan98/minotaur/utils/hash"
"github.com/kercylan98/minotaur/utils/concurrent"
"sync"
)
@ -10,7 +9,7 @@ import (
func NewDataBuried[DataID comparable, Data any](name string, hitLogic HitLogic[Data], options ...DataBuriedOption[DataID, Data]) *DataBuried[DataID, Data] {
buried := &DataBuried[DataID, Data]{
name: name,
data: asynchronous.NewMap[DataID, Data](),
data: concurrent.NewBalanceMap[DataID, Data](),
hitLogic: hitLogic,
}
buried.setData = func(id DataID, data Data) {
@ -29,7 +28,7 @@ func NewDataBuried[DataID comparable, Data any](name string, hitLogic HitLogic[D
// - 数据埋点通常用于统计不同类型的数据,例如用户数据、商城数据等
type DataBuried[DataID comparable, Data any] struct {
name string
data hash.Map[DataID, Data]
data *concurrent.BalanceMap[DataID, Data]
hitLogic HitLogic[Data]
getData func(DataID) Data
setData func(id DataID, data Data)