github.com/iikira/iikira-go-utils@v0.0.0-20230610031953-f2cb11cde33a/requester/rio/speeds/ratelimit_test.go (about) 1 package speeds_test 2 3 import ( 4 "fmt" 5 "github.com/iikira/iikira-go-utils/requester/rio/speeds" 6 "testing" 7 "time" 8 ) 9 10 func TestRateLimit(t *testing.T) { 11 r := speeds.NewRateLimit(100) 12 fmt.Println("adding 101...") 13 r.Add(101) 14 fmt.Println("adding 10...") 15 r.Add(10) 16 fmt.Println("adding 11...") 17 r.Add(11) 18 fmt.Println("adding 12...") 19 r.Add(12) 20 fmt.Println("adding 13...") 21 r.Add(13) 22 fmt.Println("adding 22...") 23 r.Add(22) 24 fmt.Println("adding 35...") 25 r.Add(35) 26 fmt.Println("adding 25...") 27 r.Add(25) 28 fmt.Println("adding 11...") 29 r.Add(11) 30 31 r.Stop() 32 time.Sleep(10e9) 33 }