package gateway

import (
	"testing"
	"time"
)

func TestRedisInteger(t *testing.T) {
	for _, value := range []any{int64(7), "7", []byte("7")} {
		got, err := redisInteger(value)
		if err != nil || got != 7 {
			t.Fatalf("redisInteger(%T) = %d, %v", value, got, err)
		}
	}
	if _, err := redisInteger(7.0); err == nil {
		t.Fatal("unexpected redis number type accepted")
	}
}

func TestAdmissionResetBoundaries(t *testing.T) {
	now := time.Date(2026, time.August, 10, 13, 25, 40, 0, time.UTC)
	minuteReset := now.Truncate(time.Minute).Add(time.Minute)
	monthReset := time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.UTC)
	if minuteReset != time.Date(2026, time.August, 10, 13, 26, 0, 0, time.UTC) {
		t.Fatal("minute boundary is incorrect")
	}
	if monthReset != time.Date(2026, time.September, 1, 0, 0, 0, 0, time.UTC) {
		t.Fatal("month boundary is incorrect")
	}
}
