Skip to content

Commit

Permalink
fix debouncer_test, replace the runtime.Gosched to the time.Sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-li committed Nov 15, 2024
1 parent aa6c8dc commit 9e88ffb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions debounce/simple_debouncer_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package debounce

import (
"runtime"
"sync/atomic"
"testing"
"time"
)

// TestDebouncer tests that the debouncer allows only one function to execute at a time
Expand Down Expand Up @@ -52,11 +52,12 @@ func TestSimpleDebouncer(t *testing.T) {
}
})
}

func waitTillChannelIsEmpty(ch chan struct{}) {
for {
if len(ch) == 0 {
return
}
runtime.Gosched()
time.Sleep(100 * time.Millisecond)
}
}

0 comments on commit 9e88ffb

Please sign in to comment.