package main

import (
	"testing"

	"./log"

	"github.com/stretchr/testify/assert"
	"go.uber.org/zap/zapcore"
)

func init() {
	log.SetDefaultLog(log.NewLogger(false, "", zapcore.DebugLevel))
}

func TestIPContainer(t *testing.T) {
	a := assert.New(t)
	c := NewIPContainer(&IPContainerConfig{
		IpLimit:      2,
		IpExpireTime: 1,
	})
	ip := "127.0.0.1"

	a.True(c.IPIncrease(ip))
	a.True(c.IPIncrease(ip))

	a.False(c.IPIncrease(ip))
	c.IPDecrease(ip)
	a.True(c.IPIncrease(ip))
}
