mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-04-01 17:34:23 +02:00
added model query autocancellation test
This commit is contained in:
parent
578e1c9bc1
commit
cf6d325add
@ -3,6 +3,7 @@ package daos_test
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pocketbase/pocketbase/daos"
|
"github.com/pocketbase/pocketbase/daos"
|
||||||
"github.com/pocketbase/pocketbase/models"
|
"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) {
|
func TestDaoFindById(t *testing.T) {
|
||||||
testApp, _ := tests.NewTestApp()
|
testApp, _ := tests.NewTestApp()
|
||||||
defer testApp.Cleanup()
|
defer testApp.Cleanup()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user