Skip to content

Commit 9ebf8a8

Browse files
committed
spanconfigkvsubscriber: use IsSortedFunc return value
Previously TestGetProtectionTimestamps called IsSortedFunc without using the return value. This commit updates these calls into assertions. Epic: none Release note: none
1 parent 8197306 commit 9ebf8a8

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

pkg/spanconfig/spanconfigkvsubscriber/kvsubscriber_test.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ func TestGetProtectionTimestamps(t *testing.T) {
113113
func(t *testing.T, m *manualStore, subscriber *KVSubscriber) {
114114
protections, _, err := subscriber.GetProtectionTimestamps(ctx, sp42)
115115
require.NoError(t, err)
116-
slices.IsSortedFunc(protections, func(a, b hlc.Timestamp) int {
117-
return a.Compare(b)
118-
})
116+
require.True(t, slices.IsSortedFunc(protections, hlc.Timestamp.Compare))
119117
require.Equal(t, []hlc.Timestamp{ts1, ts2}, protections)
120118
},
121119
},
@@ -124,9 +122,7 @@ func TestGetProtectionTimestamps(t *testing.T) {
124122
func(t *testing.T, m *manualStore, subscriber *KVSubscriber) {
125123
protections, _, err := subscriber.GetProtectionTimestamps(ctx, sp43)
126124
require.NoError(t, err)
127-
slices.IsSortedFunc(protections, func(a, b hlc.Timestamp) int {
128-
return a.Compare(b)
129-
})
125+
require.True(t, slices.IsSortedFunc(protections, hlc.Timestamp.Compare))
130126
require.Equal(t, []hlc.Timestamp{ts4}, protections)
131127
},
132128
},
@@ -135,9 +131,7 @@ func TestGetProtectionTimestamps(t *testing.T) {
135131
func(t *testing.T, m *manualStore, subscriber *KVSubscriber) {
136132
protections, _, err := subscriber.GetProtectionTimestamps(ctx, sp4243)
137133
require.NoError(t, err)
138-
slices.IsSortedFunc(protections, func(a, b hlc.Timestamp) int {
139-
return a.Compare(b)
140-
})
134+
require.True(t, slices.IsSortedFunc(protections, hlc.Timestamp.Compare))
141135
require.Equal(t, []hlc.Timestamp{ts1, ts2, ts4}, protections)
142136
},
143137
},
@@ -146,9 +140,7 @@ func TestGetProtectionTimestamps(t *testing.T) {
146140
func(t *testing.T, m *manualStore, subscriber *KVSubscriber) {
147141
protections, _, err := subscriber.GetProtectionTimestamps(ctx, keys.ExcludeFromBackupSpan)
148142
require.NoError(t, err)
149-
slices.IsSortedFunc(protections, func(a, b hlc.Timestamp) int {
150-
return a.Compare(b)
151-
})
143+
require.True(t, slices.IsSortedFunc(protections, hlc.Timestamp.Compare))
152144
require.Empty(t, protections)
153145
},
154146
},
@@ -157,9 +149,7 @@ func TestGetProtectionTimestamps(t *testing.T) {
157149
func(t *testing.T, m *manualStore, subscriber *KVSubscriber) {
158150
protections, _, err := subscriber.GetProtectionTimestamps(ctx, keys.NodeLivenessSpan)
159151
require.NoError(t, err)
160-
slices.IsSortedFunc(protections, func(a, b hlc.Timestamp) int {
161-
return a.Compare(b)
162-
})
152+
require.True(t, slices.IsSortedFunc(protections, hlc.Timestamp.Compare))
163153
require.Empty(t, protections)
164154
},
165155
},
@@ -171,9 +161,7 @@ func TestGetProtectionTimestamps(t *testing.T) {
171161
roachpb.Span{Key: keys.MinKey, EndKey: sp43.EndKey},
172162
)
173163
require.NoError(t, err)
174-
slices.IsSortedFunc(protections, func(a, b hlc.Timestamp) int {
175-
return a.Compare(b)
176-
})
164+
require.True(t, slices.IsSortedFunc(protections, hlc.Timestamp.Compare))
177165
require.Equal(t, []hlc.Timestamp{ts1, ts2, ts4}, protections)
178166
},
179167
},

0 commit comments

Comments
 (0)