Skip to content

hashicorp/lint-consul-retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

lint-consul-retry

Checks if function literal in consul/sdk/testutil/retry.Run uses t *testing.T.

retry.Run needs to operate on retry.R rather than testing.T, else the function will not retry on errors.

Examples:

Bad:

require := require.New(t)

retry.Run(t, func(r *retry.R) {
  require.NotNil(err)
}
retry.Run(t, func(r *retry.R) {
  assert.NotNil(t, err)
}
retry.Run(t, func(r *retry.R) {
  if err := myFunc(); err != nil {
    t.Fatalf("failing")
   }
}

OK:

retry.Run(t, func(r *retry.R) {
  require.NotNil(r, err)
}
retry.Run(t, func(t *retry.R) {
  assert.NotNil(t, err)
}
retry.Run(t, func(r *retry.R) {
  if err := myFunc(); err != nil {
    r.Fatalf("failing")
   }
}

Usage:

Run ./lint-consul-retry from the base directory of Consul.

About

Checks if consul/sdk/testutil/retry.Run uses testing.T

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages