mirror of
https://github.com/rclone/rclone.git
synced 2025-11-23 21:44:49 +02:00
build: use "for i := range n", added in go1.22
This commit is contained in:
@@ -200,7 +200,7 @@ func TestFilePool_ConcurrentAccess(t *testing.T) {
|
|||||||
pool := newFilePool(ctx, fs, "testshare", "/test/path")
|
pool := newFilePool(ctx, fs, "testshare", "/test/path")
|
||||||
|
|
||||||
const numGoroutines = 10
|
const numGoroutines = 10
|
||||||
for i := 0; i < numGoroutines; i++ {
|
for range numGoroutines {
|
||||||
mockFile := newMockFile()
|
mockFile := newMockFile()
|
||||||
pool.pool = append(pool.pool, mockFile)
|
pool.pool = append(pool.pool, mockFile)
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ func TestFilePool_ConcurrentAccess(t *testing.T) {
|
|||||||
// Test concurrent get operations
|
// Test concurrent get operations
|
||||||
done := make(chan bool, numGoroutines)
|
done := make(chan bool, numGoroutines)
|
||||||
|
|
||||||
for i := 0; i < numGoroutines; i++ {
|
for range numGoroutines {
|
||||||
go func() {
|
go func() {
|
||||||
defer func() { done <- true }()
|
defer func() { done <- true }()
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ func TestFilePool_ConcurrentAccess(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < numGoroutines; i++ {
|
for range numGoroutines {
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func makeTestFiles(t *testing.T, r *fstest.Run, dir string) []fstest.Item {
|
|||||||
items := []fstest.Item{}
|
items := []fstest.Item{}
|
||||||
for _, c := range alphabet {
|
for _, c := range alphabet {
|
||||||
var out strings.Builder
|
var out strings.Builder
|
||||||
for i := rune(0); i < 7; i++ {
|
for i := range rune(7) {
|
||||||
out.WriteRune(c + i)
|
out.WriteRune(c + i)
|
||||||
}
|
}
|
||||||
fileName := path.Join(dir, fmt.Sprintf("%04d-%s.txt", n, out.String()))
|
fileName := path.Join(dir, fmt.Sprintf("%04d-%s.txt", n, out.String()))
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func (r *results) checkBase32768() {
|
|||||||
// Create test files
|
// Create test files
|
||||||
for _, c := range safeAlphabet {
|
for _, c := range safeAlphabet {
|
||||||
var out strings.Builder
|
var out strings.Builder
|
||||||
for i := rune(0); i < 32; i++ {
|
for i := range rune(32) {
|
||||||
out.WriteRune(c + i)
|
out.WriteRune(c + i)
|
||||||
}
|
}
|
||||||
fileName := filepath.Join(dir, fmt.Sprintf("%04d-%s.txt", n, out.String()))
|
fileName := filepath.Join(dir, fmt.Sprintf("%04d-%s.txt", n, out.String()))
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ func (r *results) checkControls() {
|
|||||||
tokens <- struct{}{}
|
tokens <- struct{}{}
|
||||||
}
|
}
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i := rune(0); i < 128; i++ {
|
for i := range rune(128) {
|
||||||
s := string(i)
|
s := string(i)
|
||||||
if i == 0 || i == '/' {
|
if i == 0 || i == '/' {
|
||||||
// We're not even going to check NULL or /
|
// We're not even going to check NULL or /
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func TestListRHelperSend(t *testing.T) {
|
|||||||
helper := NewHelper(callback)
|
helper := NewHelper(callback)
|
||||||
|
|
||||||
// Add 100 entries to force the callback to be invoked
|
// Add 100 entries to force the callback to be invoked
|
||||||
for i := 0; i < 100; i++ {
|
for range 100 {
|
||||||
require.NoError(t, helper.Add(entry))
|
require.NoError(t, helper.Add(entry))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ var _ fs.ListPer = (*mockListPfs)(nil)
|
|||||||
func TestListWithListP(t *testing.T) {
|
func TestListWithListP(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var entries fs.DirEntries
|
var entries fs.DirEntries
|
||||||
for i := 0; i < 26; i++ {
|
for i := range 26 {
|
||||||
entries = append(entries, mockobject.New(fmt.Sprintf("%c", 'A'+i)))
|
entries = append(entries, mockobject.New(fmt.Sprintf("%c", 'A'+i)))
|
||||||
}
|
}
|
||||||
t.Run("NoError", func(t *testing.T) {
|
t.Run("NoError", func(t *testing.T) {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ func testSorterExt(t *testing.T, cutoff, N int, wantExtSort bool, keyFn KeyFn) {
|
|||||||
|
|
||||||
// Make the directory entries
|
// Make the directory entries
|
||||||
entriesMap := make(map[string]fs.DirEntry, N)
|
entriesMap := make(map[string]fs.DirEntry, N)
|
||||||
for i := 0; i < N; i++ {
|
for i := range N {
|
||||||
remote := fmt.Sprintf("%010d", i)
|
remote := fmt.Sprintf("%010d", i)
|
||||||
prefix := "a"
|
prefix := "a"
|
||||||
if i%3 == 0 {
|
if i%3 == 0 {
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ func TestJobRunPanic(t *testing.T) {
|
|||||||
runtime.Gosched() // yield to make sure job is updated
|
runtime.Gosched() // yield to make sure job is updated
|
||||||
|
|
||||||
// Wait a short time for the panic to propagate
|
// Wait a short time for the panic to propagate
|
||||||
for i := uint(0); i < 10; i++ {
|
for i := range uint(10) {
|
||||||
job.mu.Lock()
|
job.mu.Lock()
|
||||||
e := job.Error
|
e := job.Error
|
||||||
job.mu.Unlock()
|
job.mu.Unlock()
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ func makeTestFiles(t *testing.T, r *fstest.Run, dir string) []fstest.Item {
|
|||||||
items := []fstest.Item{}
|
items := []fstest.Item{}
|
||||||
for _, c := range alphabet {
|
for _, c := range alphabet {
|
||||||
var out strings.Builder
|
var out strings.Builder
|
||||||
for i := rune(0); i < 7; i++ {
|
for i := range rune(7) {
|
||||||
out.WriteRune(c + i)
|
out.WriteRune(c + i)
|
||||||
}
|
}
|
||||||
fileName := path.Join(dir, fmt.Sprintf("%04d-%s.txt", n, out.String()))
|
fileName := path.Join(dir, fmt.Sprintf("%04d-%s.txt", n, out.String()))
|
||||||
|
|||||||
Reference in New Issue
Block a user