Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Jun 16, 2023
1 parent 8c45d6d commit 3966aa6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 240 deletions.
3 changes: 1 addition & 2 deletions pkg/rlptools/limit_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/log"
)
Expand Down Expand Up @@ -371,7 +370,7 @@ func TestLimitIndexAddLimit(t *testing.T) {
variables = []string{"c", "d"}
)

limit := &kuadrantv1beta1.Limit{
limit := &Limit{
Conditions: conditions, MaxValue: maxValue, Seconds: seconds, Variables: variables,
}

Expand Down
54 changes: 27 additions & 27 deletions pkg/rlptools/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func rlp_1limit_1rate(ns, name string) kuadrantv1beta2.RateLimitPolicy {
return kuadrantv1beta2.RateLimitPolicy{
func rlp_1limit_1rate(ns, name string) *kuadrantv1beta2.RateLimitPolicy {
return &kuadrantv1beta2.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
Expand All @@ -37,8 +37,8 @@ func rlp_1limit_1rate(ns, name string) kuadrantv1beta2.RateLimitPolicy {
}
}

func rlp_2limit_1rate(ns, name string) kuadrantv1beta2.RateLimitPolicy {
return kuadrantv1beta2.RateLimitPolicy{
func rlp_2limit_1rate(ns, name string) *kuadrantv1beta2.RateLimitPolicy {
return &kuadrantv1beta2.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
Expand Down Expand Up @@ -72,8 +72,8 @@ func rlp_2limit_1rate(ns, name string) kuadrantv1beta2.RateLimitPolicy {
}
}

func rlp_1limit_2rate(ns, name string) kuadrantv1beta2.RateLimitPolicy {
return kuadrantv1beta2.RateLimitPolicy{
func rlp_1limit_2rate(ns, name string) *kuadrantv1beta2.RateLimitPolicy {
return &kuadrantv1beta2.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
Expand Down Expand Up @@ -103,8 +103,8 @@ func rlp_1limit_2rate(ns, name string) kuadrantv1beta2.RateLimitPolicy {
}
}

func rlp_1limit_1rate_1counter(ns, name string) kuadrantv1beta2.RateLimitPolicy {
return kuadrantv1beta2.RateLimitPolicy{
func rlp_1limit_1rate_1counter(ns, name string) *kuadrantv1beta2.RateLimitPolicy {
return &kuadrantv1beta2.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
Expand Down Expand Up @@ -135,7 +135,7 @@ func rlp_1limit_1rate_1counter(ns, name string) kuadrantv1beta2.RateLimitPolicy
func TestReadLimitsFromRLP(t *testing.T) {
testCases := []struct {
name string
rlp kuadrantv1beta2.RateLimitPolicy
rlp *kuadrantv1beta2.RateLimitPolicy
expectedLimits []Limit
}{
{
Expand Down Expand Up @@ -222,72 +222,72 @@ func TestConvertRateIntoSeconds(t *testing.T) {
}{
{
name: "seconds",
rate: {
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("second"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("second"),
},
expectedMaxValue: 5,
expectedSeconds: 2,
},
{
name: "minutes",
rate: {
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("minute"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("minute"),
},
expectedMaxValue: 5,
expectedSeconds: 2 * 60,
},
{
name: "hours",
rate: {
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("hour"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("hour"),
},
expectedMaxValue: 5,
expectedSeconds: 2 * 60 * 60,
},
{
name: "day",
rate: {
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("day"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("day"),
},
expectedMaxValue: 5,
expectedSeconds: 2 * 60 * 60 * 24,
},
{
name: "negative limit",
rate: {
Limit: -5, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("second"),
rate: kuadrantv1beta2.Rate{
Limit: -5, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("second"),
},
expectedMaxValue: 0,
expectedSeconds: 2,
},
{
name: "negative duration",
rate: {
Limit: 5, Duration: -2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("second"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: -2, Unit: kuadrantv1beta2.TimeUnit("second"),
},
expectedMaxValue: 5,
expectedSeconds: 0,
},
{
name: "limit is 0",
rate: {
Limit: 0, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("second"),
rate: kuadrantv1beta2.Rate{
Limit: 0, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("second"),
},
expectedMaxValue: 0,
expectedSeconds: 2,
},
{
name: "rate is 0",
rate: {
Limit: 5, Duration: 0, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("second"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: 0, Unit: kuadrantv1beta2.TimeUnit("second"),
},
expectedMaxValue: 5,
expectedSeconds: 0,
},
{
name: "unexpected time unit",
rate: {
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.kuadrantv1beta2.TimeUnit("unknown"),
rate: kuadrantv1beta2.Rate{
Limit: 5, Duration: 2, Unit: kuadrantv1beta2.TimeUnit("unknown"),
},
expectedMaxValue: 5,
expectedSeconds: 0,
Expand Down
Loading

0 comments on commit 3966aa6

Please sign in to comment.