diff options
Diffstat (limited to 'internal/lsp/debounce_throttle_more_test.go')
| -rw-r--r-- | internal/lsp/debounce_throttle_more_test.go | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/internal/lsp/debounce_throttle_more_test.go b/internal/lsp/debounce_throttle_more_test.go index cb11ea4..ed61336 100644 --- a/internal/lsp/debounce_throttle_more_test.go +++ b/internal/lsp/debounce_throttle_more_test.go @@ -1,36 +1,35 @@ package lsp import ( - "context" - "testing" - "time" + "context" + "testing" + "time" ) func TestWaitForDebounce_WaitsRoughlyDebounce(t *testing.T) { - s := newTestServer() - s.completionDebounce = 20 * time.Millisecond - s.mu.Lock() - s.lastInput = time.Now() - s.mu.Unlock() - start := time.Now() - s.waitForDebounce(context.Background()) - if elapsed := time.Since(start); elapsed < 15*time.Millisecond { - t.Fatalf("debounce did not wait long enough: %v", elapsed) - } + s := newTestServer() + s.completionDebounce = 20 * time.Millisecond + s.mu.Lock() + s.lastInput = time.Now() + s.mu.Unlock() + start := time.Now() + s.waitForDebounce(context.Background()) + if elapsed := time.Since(start); elapsed < 15*time.Millisecond { + t.Fatalf("debounce did not wait long enough: %v", elapsed) + } } func TestWaitForThrottle_WaitsRoughlyInterval(t *testing.T) { - s := newTestServer() - s.throttleInterval = 20 * time.Millisecond - s.mu.Lock() - s.lastLLMCall = time.Now() - s.mu.Unlock() - start := time.Now() - if !s.waitForThrottle(context.Background()) { - t.Fatalf("waitForThrottle returned false") - } - if elapsed := time.Since(start); elapsed < 15*time.Millisecond { - t.Fatalf("throttle did not wait long enough: %v", elapsed) - } + s := newTestServer() + s.throttleInterval = 20 * time.Millisecond + s.mu.Lock() + s.lastLLMCall = time.Now() + s.mu.Unlock() + start := time.Now() + if !s.waitForThrottle(context.Background()) { + t.Fatalf("waitForThrottle returned false") + } + if elapsed := time.Since(start); elapsed < 15*time.Millisecond { + t.Fatalf("throttle did not wait long enough: %v", elapsed) + } } - |
