mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
chore(code): use int ranges in loops BE-10990 (#12028)
This commit is contained in:
parent
468c12c75b
commit
31bdb948a8
12 changed files with 183 additions and 169 deletions
|
@ -157,28 +157,33 @@ func Test_customTemplateGitFetch(t *testing.T) {
|
|||
t.Run("can return the expected file content by multiple calls from one user", func(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(5)
|
||||
for i := 0; i < 5; i++ {
|
||||
|
||||
for range 5 {
|
||||
go func() {
|
||||
singleAPIRequest(h, jwt1, is, "abcdefg")
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
})
|
||||
|
||||
t.Run("can return the expected file content by multiple calls from different users", func(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
for i := 0; i < 10; i++ {
|
||||
|
||||
for i := range 10 {
|
||||
go func(j int) {
|
||||
if j%2 == 0 {
|
||||
singleAPIRequest(h, jwt1, is, "abcdefg")
|
||||
} else {
|
||||
singleAPIRequest(h, jwt2, is, "abcdefg")
|
||||
}
|
||||
|
||||
wg.Done()
|
||||
}(i)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
})
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestEndpointDeleteEdgeGroupsConcurrently(t *testing.T) {
|
|||
|
||||
var endpointIDs []portainer.EndpointID
|
||||
|
||||
for i := 0; i < endpointsCount; i++ {
|
||||
for i := range endpointsCount {
|
||||
endpointID := portainer.EndpointID(i) + 1
|
||||
|
||||
if err := store.Endpoint().Create(&portainer.Endpoint{
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestTagDeleteEdgeGroupsConcurrently(t *testing.T) {
|
|||
|
||||
var tagIDs []portainer.TagID
|
||||
|
||||
for i := 0; i < tagsCount; i++ {
|
||||
for i := range tagsCount {
|
||||
tagID := portainer.TagID(i) + 1
|
||||
|
||||
if err := store.Tag().Create(&portainer.Tag{
|
||||
|
|
|
@ -27,7 +27,7 @@ func failFunc(t *testing.T) func() (string, error) {
|
|||
func TestTokenCacheDataRace(t *testing.T) {
|
||||
ch := make(chan struct{})
|
||||
|
||||
for i := 0; i < 1000; i++ {
|
||||
for range 1000 {
|
||||
var tokenCache1, tokenCache2 *tokenCache
|
||||
|
||||
mgr := NewTokenCacheManager()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue