Skip to content

Commit c546e58

Browse files
committed
lint more
1 parent 27c52f0 commit c546e58

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

client/matching/partition_cache_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"sync"
55
"testing"
66

7-
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
88
enumspb "go.temporal.io/api/enums/v1"
99
"go.temporal.io/server/common/metrics"
1010
)
@@ -26,19 +26,19 @@ func TestPartitionCache_BasicPutLookup(t *testing.T) {
2626

2727
c.put(key, pc4)
2828
c.put(keyb, pc8)
29-
assert.Equal(t, pc4, c.lookup(key))
30-
assert.Equal(t, pc8, c.lookup(keyb))
29+
require.Equal(t, pc4, c.lookup(key))
30+
require.Equal(t, pc8, c.lookup(keyb))
3131

3232
c.put(key, pc8)
33-
assert.Equal(t, pc8, c.lookup(key))
33+
require.Equal(t, pc8, c.lookup(key))
3434

3535
// missing key
3636
keyc := c.makeKey(testNsID, "nonexistent", enumspb.TASK_QUEUE_TYPE_WORKFLOW)
37-
assert.Equal(t, PartitionCounts{}, c.lookup(keyc))
37+
require.Equal(t, PartitionCounts{}, c.lookup(keyc))
3838

3939
// removes
4040
c.put(key, PartitionCounts{Read: -3, Write: -5})
41-
assert.Equal(t, PartitionCounts{}, c.lookup(key))
41+
require.Equal(t, PartitionCounts{}, c.lookup(key))
4242
}
4343

4444
func TestPartitionCache_Rotate(t *testing.T) {
@@ -55,17 +55,17 @@ func TestPartitionCache_Rotate(t *testing.T) {
5555
c.shards[c.shardFromKey(key)].rotate()
5656

5757
// Lookup should still find it (promotes from prev to active)
58-
assert.Equal(t, pc, c.lookup(key))
58+
require.Equal(t, pc, c.lookup(key))
5959

6060
// After promotion, rotate again — it should still be in active
6161
c.shards[c.shardFromKey(key)].rotate()
62-
assert.Equal(t, pc, c.lookup(key))
62+
require.Equal(t, pc, c.lookup(key))
6363

6464
// Rotate twice without any lookup — entry should be gone
6565
c.shards[c.shardFromKey(key)].rotate()
6666
c.shards[c.shardFromKey(key)].rotate()
6767

68-
assert.Equal(t, PartitionCounts{}, c.lookup(key))
68+
require.Equal(t, PartitionCounts{}, c.lookup(key))
6969
}
7070

7171
func TestPartitionCache_ConcurrentAccess(t *testing.T) {

client/matching/partition_counts_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package matching
22

33
import (
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

6363
func 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

8484
func 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

105105
func 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

131131
func 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

154154
func 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

177177
func 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

197197
func 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

217217
func 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

241241
func 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

Comments
 (0)