func (s *LimiterSuite) TestFailure(c *C) {
	rates := NewRateSet()
	rates.Add(time.Second, 1, 1)
	tl, err := NewLimiter(rates, 0, limit.MapClientIp, nil, s.clock)
	c.Assert(err, IsNil)
	_, err = tl.ProcessRequest(makeRequest(""))
	c.Assert(err, NotNil)
}
We've failed to extract client ip
package tokenbucket
import (
	"fmt"
	"net/http"
	"time"
	"github.com/mailgun/timetools"
	"github.com/mailgun/vulcan/limit"
	"github.com/mailgun/vulcan/request"
	. "gopkg.in/check.v1"
)
type LimiterSuite struct {
	clock *timetools.FreezedTime
}
var _ = Suite(&LimiterSuite{})
func (s *LimiterSuite) SetUpSuite(c *C) {
	s.clock = &timetools.FreezedTime{
		CurrentTime: time.Date(2012, 3, 4, 5, 6, 7, 0, time.UTC),
	}
}
func (s *LimiterSuite) TestRateSetAdd(c *C) {
	rs := NewRateSet()
	err := rs.Add(0, 1, 1)
	c.Assert(err, NotNil)
	err = rs.Add(time.Second, 0, 1)
	c.Assert(err, NotNil)
	err = rs.Add(time.Second, 1, 0)
	c.Assert(err, NotNil)
	err = rs.Add(time.Second, 1, 1)
	c.Assert(err, IsNil)
	c.Assert("map[1s:rate(1/1s, burst=1)]", Equals, fmt.Sprint(rs))
}
func (s *LimiterSuite) TestHitLimit(c *C) {
	rates := NewRateSet()
	rates.Add(time.Second, 1, 1)
	tl, err := NewLimiter(rates, 0, limit.MapClientIp, nil, s.clock)
	c.Assert(err, IsNil)
	re, err := tl.ProcessRequest(makeRequest("1.2.3.4"))
	c.Assert(re, IsNil)
	c.Assert(err, IsNil)
	re, err = tl.ProcessRequest(makeRequest("1.2.3.4"))
	c.Assert(re, NotNil)
	c.Assert(err, IsNil)
	s.clock.Sleep(time.Second)
	re, err = tl.ProcessRequest(makeRequest("1.2.3.4"))
	c.Assert(re, IsNil)
	c.Assert(err, IsNil)
}