@@ -92,9 +92,7 @@ func TestOperation_io_read_limit(t *testing.T) {
9292func TestOperation_read_rate_low (t * testing.T ) {
9393 ctx , cancel := context .WithTimeout (context .Background (), time .Second * 2 )
9494 defer cancel ()
95- l := NewLimiter (ctx )
96-
97- l .Reads .Limit .Store (1000 ) // 10 bytes @ 1000/sec
95+ l := NewLimiter (ctx , 1000 )
9896
9997 now := time .Now ()
10098 r := bytes .NewReader (make ([]byte , 2000 ))
@@ -109,6 +107,7 @@ func TestOperation_read_rate_low(t *testing.T) {
109107 }
110108
111109 if elapsed := time .Since (now ); elapsed < time .Millisecond * 900 || elapsed > time .Millisecond * 1100 {
110+ t .Log (l .Reads .Limit .Load ())
112111 t .Error (elapsed )
113112 }
114113 if rate := int (l .Reads .Rate .Load ()); rate < 990 || rate > 1000 {
@@ -119,10 +118,8 @@ func TestOperation_read_rate_low(t *testing.T) {
119118func TestOperation_read_rate_high (t * testing.T ) {
120119 ctx , cancel := context .WithTimeout (context .Background (), time .Second )
121120 defer cancel ()
122- l := NewLimiter (ctx )
123-
124121 const numbytes = (2 * 1024 * 1024 * 1024 ) - 1
125- l . Reads . Limit . Store ( numbytes )
122+ l := NewLimiter ( ctx , numbytes )
126123
127124 now := time .Now ()
128125 r := & unlimitedReader {}
@@ -158,8 +155,8 @@ func TestOperation_read_rate_high(t *testing.T) {
158155func TestOperation_write_rate (t * testing.T ) {
159156 ctx , cancel := context .WithTimeout (context .Background (), time .Second * 2 )
160157 defer cancel ()
161- l := NewLimiter ( ctx )
162- l . Writes . Limit . Store ( 1000000 )
158+
159+ l := NewLimiter ( ctx , 1000000 )
163160
164161 buf := make ([]byte , 10000 )
165162
0 commit comments