mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-25 06:26:34 +08:00
改进单元测试,以便于可以使用go test ../...进行执行
This commit is contained in:
@@ -50,6 +50,10 @@ func (this *testCacheItemEncoder[T]) EncodeField(value T, fieldName string) ([]b
|
||||
func TestTable_AddField(t *testing.T) {
|
||||
var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
|
||||
|
||||
defer func() {
|
||||
_ = testingStore.Close()
|
||||
}()
|
||||
|
||||
err := table.AddFields("expiresAt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -103,6 +107,10 @@ func TestTable_AddField_Many(t *testing.T) {
|
||||
|
||||
var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
|
||||
|
||||
defer func() {
|
||||
_ = testingStore.Close()
|
||||
}()
|
||||
|
||||
{
|
||||
err := table.AddFields("expiresAt")
|
||||
if err != nil {
|
||||
@@ -157,6 +165,10 @@ func TestTable_AddField_Delete_Many(t *testing.T) {
|
||||
|
||||
var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
|
||||
|
||||
defer func() {
|
||||
_ = testingStore.Close()
|
||||
}()
|
||||
|
||||
{
|
||||
err := table.AddFields("expiresAt")
|
||||
if err != nil {
|
||||
@@ -205,6 +217,10 @@ func TestTable_AddField_Delete_Many(t *testing.T) {
|
||||
func TestTable_DropField(t *testing.T) {
|
||||
var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
|
||||
|
||||
defer func() {
|
||||
_ = testingStore.Close()
|
||||
}()
|
||||
|
||||
var before = time.Now()
|
||||
defer func() {
|
||||
var costSeconds = time.Since(before).Seconds()
|
||||
@@ -242,6 +258,10 @@ func TestTable_DropField(t *testing.T) {
|
||||
func TestTable_Inspect(t *testing.T) {
|
||||
var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
|
||||
|
||||
defer func() {
|
||||
_ = testingStore.Close()
|
||||
}()
|
||||
|
||||
err := table.AddFields("expiresAt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user