@@ -164,20 +164,20 @@ func TestSign_RetryBehavior(t *testing.T) {
164164 t .Run (name , func (t * testing.T ) {
165165 _ , publicKeyPEM := generateTestEd25519PEM (t )
166166
167- var calls int32
167+ var calls atomic. Int32
168168 signer := newTestSigner (t , & mockKMSClient {
169169 keyID : myKeyID ,
170170 publicKeyPEM : publicKeyPEM ,
171171 signFn : func (_ context.Context , _ * kmspb.AsymmetricSignRequest ) (* kmspb.AsymmetricSignResponse , error ) {
172- atomic . AddInt32 ( & calls , 1 )
172+ calls . Add ( 1 )
173173 return nil , spec .signErr
174174 },
175175 }, spec .opts )
176176
177177 _ , err := signer .Sign (t .Context (), []byte ("hello world" ))
178178 require .Error (t , err )
179179 assert .Contains (t , err .Error (), spec .errSubstr )
180- assert .Equal (t , spec .expectedCall , atomic . LoadInt32 ( & calls ))
180+ assert .Equal (t , spec .expectedCall , calls . Load ( ))
181181 })
182182 }
183183}
@@ -228,34 +228,34 @@ func TestSign_IntegrityFailures_RetryAndFail(t *testing.T) {
228228 t .Run (name , func (t * testing.T ) {
229229 _ , publicKeyPEM := generateTestEd25519PEM (t )
230230
231- var calls int32
231+ var calls atomic. Int32
232232 signer := newTestSigner (t , & mockKMSClient {
233233 keyID : myKeyID ,
234234 publicKeyPEM : publicKeyPEM ,
235235 signFn : func (_ context.Context , _ * kmspb.AsymmetricSignRequest ) (* kmspb.AsymmetricSignResponse , error ) {
236- atomic . AddInt32 ( & calls , 1 )
236+ calls . Add ( 1 )
237237 return spec .responseFn (), nil
238238 },
239239 }, & Options {MaxRetries : 1 })
240240
241241 _ , err := signer .Sign (t .Context (), []byte ("hello world" ))
242242 require .Error (t , err )
243243 assert .Contains (t , err .Error (), spec .expectedErrSubstr )
244- assert .Equal (t , int32 (2 ), atomic . LoadInt32 ( & calls ), "integrity failures should be retried" )
244+ assert .Equal (t , int32 (2 ), calls . Load ( ), "integrity failures should be retried" )
245245 })
246246 }
247247}
248248
249249func TestSign_IntegrityCheckRecoversOnRetry (t * testing.T ) {
250250 _ , publicKeyPEM := generateTestEd25519PEM (t )
251251
252- var calls int32
252+ var calls atomic. Int32
253253 expectedSig := []byte ("valid-signature" )
254254 mock := & mockKMSClient {
255255 keyID : myKeyID ,
256256 publicKeyPEM : publicKeyPEM ,
257257 signFn : func (_ context.Context , _ * kmspb.AsymmetricSignRequest ) (* kmspb.AsymmetricSignResponse , error ) {
258- attempt := atomic . AddInt32 ( & calls , 1 )
258+ attempt := calls . Add ( 1 )
259259 if attempt == 1 {
260260 return & kmspb.AsymmetricSignResponse {
261261 Name : myKeyID ,
@@ -278,7 +278,7 @@ func TestSign_IntegrityCheckRecoversOnRetry(t *testing.T) {
278278 got , err := s .Sign (t .Context (), []byte ("hello world" ))
279279 require .NoError (t , err )
280280 assert .Equal (t , expectedSig , got )
281- assert .Equal (t , int32 (2 ), atomic . LoadInt32 ( & calls ), "second attempt should succeed" )
281+ assert .Equal (t , int32 (2 ), calls . Load ( ), "second attempt should succeed" )
282282}
283283
284284func TestRetryBackoff_Capped (t * testing.T ) {
0 commit comments