44 "context"
55 "testing"
66
7+ "github.com/stretchr/testify/require"
78 "google.golang.org/protobuf/proto"
89
910 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Table"
@@ -15,18 +16,28 @@ import (
1516
1617func TestQueryCachePolicyKeepInCache (t * testing.T ) {
1718 for _ , test := range [... ]struct {
18- name string
19- queryCachePolicyOption []options.QueryCachePolicyOption
19+ name string
20+ executeDataQueryOptions []options.ExecuteDataQueryOption
21+ keepInCache bool
2022 }{
23+ {
24+ name : "no options" ,
25+ executeDataQueryOptions : nil ,
26+ keepInCache : true ,
27+ },
2128 {
2229 name : "with server cache" ,
23- queryCachePolicyOption : []options.QueryCachePolicyOption {
24- options .WithQueryCachePolicyKeepInCache ( ),
30+ executeDataQueryOptions : []options.ExecuteDataQueryOption {
31+ options .WithKeepInCache ( true ),
2532 },
33+ keepInCache : true ,
2634 },
2735 {
28- name : "no server cache" ,
29- queryCachePolicyOption : []options.QueryCachePolicyOption {},
36+ name : "no server cache" ,
37+ executeDataQueryOptions : []options.ExecuteDataQueryOption {
38+ options .WithKeepInCache (false ),
39+ },
40+ keepInCache : false ,
3041 },
3142 } {
3243 t .Run (test .name , func (t * testing.T ) {
@@ -41,15 +52,7 @@ func TestQueryCachePolicyKeepInCache(t *testing.T) {
4152 if ! ok {
4253 t .Fatalf ("cannot cast request '%T' to *Ydb_Table.ExecuteDataQueryRequest" , request )
4354 }
44- if len (test .queryCachePolicyOption ) > 0 {
45- if ! r .QueryCachePolicy .GetKeepInCache () {
46- t .Fatalf ("keep-in-cache policy must be true, got: %v" , r .QueryCachePolicy .GetKeepInCache ())
47- }
48- } else {
49- if r .QueryCachePolicy .GetKeepInCache () {
50- t .Fatalf ("keep-in-cache policy must be false, got: %v" , r .QueryCachePolicy .GetKeepInCache ())
51- }
52- }
55+ require .Equal (t , test .keepInCache , r .QueryCachePolicy .GetKeepInCache ())
5356 return & Ydb_Table.ExecuteQueryResult {
5457 TxMeta : & Ydb_Table.TransactionMeta {
5558 Id : "" ,
@@ -79,7 +82,7 @@ func TestQueryCachePolicyKeepInCache(t *testing.T) {
7982 ),
8083 "SELECT 1" ,
8184 table .NewQueryParameters (),
82- options . WithQueryCachePolicy ( test .queryCachePolicyOption ... ) ,
85+ test .executeDataQueryOptions ... ,
8386 )
8487 if err != nil {
8588 t .Fatal (err )
0 commit comments