package ratelimit

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestCheckMethod(t *testing.T) {
	method1 := "/central.ClusterService/SendPasswordVerifyCode"
	method2 := "/central.TenantService/InviteUser"
	methods1 := []Method{
		{
			Name: "/central.ClusterService/SendPasswordVerifyCode",
		},
	}
	methods2 := []Method{
		{
			Name: "*",
		},
	}

	ret1 := checkMethod(method1, methods1)
	assert.True(t, ret1)

	ret2 := checkMethod(method2, methods1)
	assert.False(t, ret2)

	ret3 := checkMethod(method1, methods2)
	assert.True(t, ret3)

	ret4 := checkMethod(method2, methods2)
	assert.True(t, ret4)
}
