mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 10:46:16 +01:00
This commit is contained in:
@@ -6,9 +6,12 @@ package tests
|
||||
|
||||
import (
|
||||
"beszel/internal/hub"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/tests"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
_ "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
@@ -86,3 +89,10 @@ func CreateRecord(app core.App, collectionName string, fields map[string]any) (*
|
||||
|
||||
return record, app.Save(record)
|
||||
}
|
||||
|
||||
func ClearCollection(t testing.TB, app core.App, collectionName string) error {
|
||||
_, err := app.DB().NewQuery(fmt.Sprintf("DELETE from %s", collectionName)).Execute()
|
||||
recordCount, err := app.CountRecords(collectionName)
|
||||
assert.EqualValues(t, recordCount, 0, "should have 0 records after clearing")
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user