mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-30 17:28:18 +02:00
added model query autocancellation test
This commit is contained in:
parent
578e1c9bc1
commit
cf6d325add
@ -3,6 +3,7 @@ package daos_test
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
@ -71,6 +72,24 @@ func TestDaoModelQuery(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDaoModelQueryCancellation(t *testing.T) {
|
||||
testApp, _ := tests.NewTestApp()
|
||||
defer testApp.Cleanup()
|
||||
|
||||
dao := daos.New(testApp.DB())
|
||||
|
||||
m := &models.Admin{}
|
||||
|
||||
if err := dao.ModelQuery(m).One(m); err != nil {
|
||||
t.Fatalf("Failed to execute control query: %v", err)
|
||||
}
|
||||
|
||||
dao.ModelQueryTimeout = 0 * time.Millisecond
|
||||
if err := dao.ModelQuery(m).One(m); err == nil {
|
||||
t.Fatal("Expected to be cancelled, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDaoFindById(t *testing.T) {
|
||||
testApp, _ := tests.NewTestApp()
|
||||
defer testApp.Cleanup()
|
||||
|
Loading…
x
Reference in New Issue
Block a user