@@ -3,6 +3,7 @@ package datastore
33import (
44 "context"
55 "testing"
6+ "time"
67
78 "github.com/stretchr/testify/require"
89
@@ -12,6 +13,37 @@ import (
1213 "github.com/authzed/spicedb/pkg/tuple"
1314)
1415
16+ func TestBuildAndValidateWatchOptions (t * testing.T ) {
17+ t .Run ("WatchBufferWriteTimeout" , func (t * testing.T ) {
18+ c , err := BuildAndValidateWatchOptions (ServerWatchConfig {WatchBufferWriteTimeout : 1 * time .Second }, ClientWatchOptions {}, WatchOptions {WatchBufferWriteTimeout : 2 * time .Second })
19+ require .NoError (t , err )
20+ require .NotNil (t , c )
21+ require .Equal (t , 2 * time .Second , c .WatchBufferWriteTimeout )
22+ })
23+ t .Run ("WatchConnectTimeout" , func (t * testing.T ) {
24+ c , err := BuildAndValidateWatchOptions (ServerWatchConfig {WatchConnectTimeout : 1 * time .Second }, ClientWatchOptions {}, WatchOptions {WatchConnectTimeout : 2 * time .Second })
25+ require .NoError (t , err )
26+ require .NotNil (t , c )
27+ require .Equal (t , 2 * time .Second , c .WatchConnectTimeout )
28+ })
29+ t .Run ("WatchBufferLength" , func (t * testing.T ) {
30+ c , err := BuildAndValidateWatchOptions (ServerWatchConfig {WatchBufferLength : 100 }, ClientWatchOptions {}, WatchOptions {WatchBufferLength : 200 })
31+ require .NoError (t , err )
32+ require .NotNil (t , c )
33+ require .Equal (t , uint16 (200 ), c .WatchBufferLength )
34+ })
35+ t .Run ("CheckpointInterval" , func (t * testing.T ) {
36+ c , err := BuildAndValidateWatchOptions (ServerWatchConfig {CheckpointInterval : 1 }, ClientWatchOptions {}, WatchOptions {CheckpointInterval : 2 })
37+ require .NoError (t , err )
38+ require .NotNil (t , c )
39+ require .Equal (t , time .Duration (2 ), c .CheckpointInterval )
40+ })
41+ t .Run ("Invalid CheckpointInterval" , func (t * testing.T ) {
42+ _ , err := BuildAndValidateWatchOptions (ServerWatchConfig {CheckpointInterval : - 1 }, ClientWatchOptions {}, WatchOptions {CheckpointInterval : - 1 })
43+ require .Error (t , err )
44+ })
45+ }
46+
1547func TestRelationshipsFilterFromPublicFilter (t * testing.T ) {
1648 tests := []struct {
1749 name string
0 commit comments