Software /
code /
prosody
Comparison
spec/util_throttle_spec.lua @ 8246:ea2667fc6781
util_throttle_spec: Slight stylistic update for function test group titles
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 17 Sep 2017 13:33:38 -0400 |
parent | 8245:9499db96c032 |
child | 8473:f024cb5acc25 |
comparison
equal
deleted
inserted
replaced
8245:9499db96c032 | 8246:ea2667fc6781 |
---|---|
11 | 11 |
12 | 12 |
13 local throttle = require "util.throttle"; | 13 local throttle = require "util.throttle"; |
14 | 14 |
15 describe("util.throttle", function() | 15 describe("util.throttle", function() |
16 describe("#create", function() | 16 describe("#create()", function() |
17 it("should be created with correct values", function() | 17 it("should be created with correct values", function() |
18 now = 5; | 18 now = 5; |
19 local a = throttle.create(3, 10); | 19 local a = throttle.create(3, 10); |
20 assert.same(a, { balance = 3, max = 3, rate = 0.3, t = 5 }); | 20 assert.same(a, { balance = 3, max = 3, rate = 0.3, t = 5 }); |
21 | 21 |
31 local a = throttle.create(10, 1); | 31 local a = throttle.create(10, 1); |
32 assert.same(a, { balance = 10, max = 10, rate = 10, t = 5 }); | 32 assert.same(a, { balance = 10, max = 10, rate = 10, t = 5 }); |
33 end); | 33 end); |
34 end); | 34 end); |
35 | 35 |
36 describe("#update", function() | 36 describe("#update()", function() |
37 it("does nothing when no time hase passed, even if balance is not full", function() | 37 it("does nothing when no time hase passed, even if balance is not full", function() |
38 now = 5; | 38 now = 5; |
39 local a = throttle.create(10, 10); | 39 local a = throttle.create(10, 10); |
40 for i=1,5 do | 40 for i=1,5 do |
41 a:update(); | 41 a:update(); |