@@ -2,9 +2,9 @@ package matching
22
33import (
44 "context"
5+ "errors"
56 "testing"
67
7- "github.com/stretchr/testify/assert"
88 "github.com/stretchr/testify/require"
99 enumspb "go.temporal.io/api/enums/v1"
1010 "go.temporal.io/server/common/log"
@@ -46,18 +46,18 @@ func TestInvokeWithPartitionCounts_CacheMissSuccess(t *testing.T) {
4646 calls := 0
4747 op := func (ctx context.Context , pc PartitionCounts , req * hpcReq , opts []grpc.CallOption ) (* hpcRes , error ) {
4848 calls ++
49- assert .Equal (t , PartitionCounts {}, pc ) // cache miss
49+ require .Equal (t , PartitionCounts {}, pc ) // cache miss
5050 setTrailerInOpts (opts , serverPC )
5151 return & hpcRes {value : "ok" }, nil
5252 }
5353
5454 res , err := invokeWithPartitionCounts (context .Background (), log .NewNoopLogger (), cache , pkey , & hpcReq {}, nil , op )
5555 require .NoError (t , err )
56- assert .Equal (t , "ok" , res .value )
57- assert .Equal (t , 1 , calls )
56+ require .Equal (t , "ok" , res .value )
57+ require .Equal (t , 1 , calls )
5858
5959 // cache should be updated
60- assert .Equal (t , serverPC , cache .lookup (pkey ))
60+ require .Equal (t , serverPC , cache .lookup (pkey ))
6161}
6262
6363func TestInvokeWithPartitionCounts_CacheHitSuccess (t * testing.T ) {
@@ -69,16 +69,16 @@ func TestInvokeWithPartitionCounts_CacheHitSuccess(t *testing.T) {
6969 cache .put (pkey , cachedPC )
7070
7171 op := func (ctx context.Context , pc PartitionCounts , req * hpcReq , opts []grpc.CallOption ) (* hpcRes , error ) {
72- assert .Equal (t , cachedPC , pc )
72+ require .Equal (t , cachedPC , pc )
7373 // server confirms same counts
7474 setTrailerInOpts (opts , cachedPC )
7575 return & hpcRes {value : "ok" }, nil
7676 }
7777
7878 res , err := invokeWithPartitionCounts (context .Background (), log .NewNoopLogger (), cache , pkey , & hpcReq {}, nil , op )
7979 require .NoError (t , err )
80- assert .Equal (t , "ok" , res .value )
81- assert .Equal (t , cachedPC , cache .lookup (pkey ))
80+ require .Equal (t , "ok" , res .value )
81+ require .Equal (t , cachedPC , cache .lookup (pkey ))
8282}
8383
8484func TestInvokeWithPartitionCounts_ServerUpdatesCount (t * testing.T ) {
@@ -99,7 +99,7 @@ func TestInvokeWithPartitionCounts_ServerUpdatesCount(t *testing.T) {
9999 require .NoError (t , err )
100100
101101 // cache should be updated
102- assert .Equal (t , newPC , cache .lookup (pkey ))
102+ require .Equal (t , newPC , cache .lookup (pkey ))
103103}
104104
105105func TestInvokeWithPartitionCounts_StaleRetry_Succeeds (t * testing.T ) {
@@ -114,18 +114,18 @@ func TestInvokeWithPartitionCounts_StaleRetry_Succeeds(t *testing.T) {
114114 calls ++
115115 setTrailerInOpts (opts , serverPC )
116116 if calls == 1 {
117- assert .Equal (t , PartitionCounts {}, pc ) // cache miss
117+ require .Equal (t , PartitionCounts {}, pc ) // cache miss
118118 return nil , serviceerrors .NewStalePartitionCounts ("stale" )
119119 }
120- assert .Equal (t , serverPC , pc ) // retry with updated counts
120+ require .Equal (t , serverPC , pc ) // retry with updated counts
121121 return & hpcRes {value : "ok" }, nil
122122 }
123123
124124 res , err := invokeWithPartitionCounts (context .Background (), log .NewNoopLogger (), cache , pkey , & hpcReq {}, nil , op )
125125 require .NoError (t , err )
126- assert .Equal (t , "ok" , res .value )
127- assert .Equal (t , 2 , calls )
128- assert .Equal (t , serverPC , cache .lookup (pkey ))
126+ require .Equal (t , "ok" , res .value )
127+ require .Equal (t , 2 , calls )
128+ require .Equal (t , serverPC , cache .lookup (pkey ))
129129}
130130
131131func TestInvokeWithPartitionCounts_StaleRetry_Fails (t * testing.T ) {
@@ -143,12 +143,12 @@ func TestInvokeWithPartitionCounts_StaleRetry_Fails(t *testing.T) {
143143 return nil , serviceerrors .NewStalePartitionCounts ("stale first" )
144144 }
145145 // second attempt: different non-stale error
146- return nil , assert . AnError
146+ return nil , errors . New ( "error" )
147147 }
148148
149149 _ , err := invokeWithPartitionCounts (context .Background (), log .NewNoopLogger (), cache , pkey , & hpcReq {}, nil , op )
150150 require .Error (t , err )
151- assert .Equal (t , 2 , calls )
151+ require .Equal (t , 2 , calls )
152152}
153153
154154func TestInvokeWithPartitionCounts_OtherErrorNoRetry (t * testing.T ) {
@@ -163,15 +163,15 @@ func TestInvokeWithPartitionCounts_OtherErrorNoRetry(t *testing.T) {
163163 calls ++
164164 // even on error, server sends trailer
165165 setTrailerInOpts (opts , serverPC )
166- return nil , assert . AnError
166+ return nil , errors . New ( "error" )
167167 }
168168
169169 _ , err := invokeWithPartitionCounts (context .Background (), log .NewNoopLogger (), cache , pkey , & hpcReq {}, nil , op )
170170 require .Error (t , err )
171- assert .Equal (t , 1 , calls ) // no retry
171+ require .Equal (t , 1 , calls ) // no retry
172172
173173 // cache should still be updated from trailer
174- assert .Equal (t , serverPC , cache .lookup (pkey ))
174+ require .Equal (t , serverPC , cache .lookup (pkey ))
175175}
176176
177177func TestInvokeWithPartitionCounts_ZeroTrailerRemovesCache (t * testing.T ) {
@@ -191,7 +191,7 @@ func TestInvokeWithPartitionCounts_ZeroTrailerRemovesCache(t *testing.T) {
191191 require .NoError (t , err )
192192
193193 // cache entry should be removed
194- assert .Equal (t , PartitionCounts {}, cache .lookup (pkey ))
194+ require .Equal (t , PartitionCounts {}, cache .lookup (pkey ))
195195}
196196
197197func TestInvokeWithPartitionCounts_NoTrailerRemovesCache (t * testing.T ) {
@@ -211,7 +211,7 @@ func TestInvokeWithPartitionCounts_NoTrailerRemovesCache(t *testing.T) {
211211 require .NoError (t , err )
212212
213213 // cache entry should be removed
214- assert .Equal (t , PartitionCounts {}, cache .lookup (pkey ))
214+ require .Equal (t , PartitionCounts {}, cache .lookup (pkey ))
215215}
216216
217217func TestInvokeWithPartitionCounts_ParseErrorRemovesCache (t * testing.T ) {
@@ -235,7 +235,7 @@ func TestInvokeWithPartitionCounts_ParseErrorRemovesCache(t *testing.T) {
235235 require .NoError (t , err )
236236
237237 // cache entry should be removed
238- assert .Equal (t , PartitionCounts {}, cache .lookup (pkey ))
238+ require .Equal (t , PartitionCounts {}, cache .lookup (pkey ))
239239}
240240
241241func TestInvokeWithPartitionCounts_OutgoingContextHasHeader (t * testing.T ) {
@@ -254,7 +254,7 @@ func TestInvokeWithPartitionCounts_OutgoingContextHasHeader(t *testing.T) {
254254 require .Len (t , vals , 1 )
255255 parsed , err := parsePartitionCounts (vals [0 ])
256256 require .NoError (t , err )
257- assert .Equal (t , cachedPC , parsed )
257+ require .Equal (t , cachedPC , parsed )
258258
259259 setTrailerInOpts (opts , cachedPC )
260260 return & hpcRes {value : "ok" }, nil
0 commit comments