mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-02 00:01:32 +02:00
Update golangci-lint from v2.11.2 to v2.11.4 and fix new `modernize` lint warnings: - Use `strings.Builder` instead of string concatenation in loop (`evaluator.go`) - Use `atomic.Int64` instead of `int64` with atomic free functions (`logchecker.go`, `timer_test.go`, `integration_test.go`) --- This PR was written with the help of Claude Opus 4.6 Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
31 lines
668 B
Go
31 lines
668 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package util
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDebounce(t *testing.T) {
|
|
var c atomic.Int64
|
|
d := Debounce(50 * time.Millisecond)
|
|
d(func() { c.Add(1) })
|
|
assert.EqualValues(t, 0, c.Load())
|
|
d(func() { c.Add(1) })
|
|
d(func() { c.Add(1) })
|
|
time.Sleep(100 * time.Millisecond)
|
|
assert.EqualValues(t, 1, c.Load())
|
|
d(func() { c.Add(1) })
|
|
assert.EqualValues(t, 1, c.Load())
|
|
d(func() { c.Add(1) })
|
|
d(func() { c.Add(1) })
|
|
d(func() { c.Add(1) })
|
|
time.Sleep(100 * time.Millisecond)
|
|
assert.EqualValues(t, 2, c.Load())
|
|
}
|