mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-23 06:26:43 +00:00
* fix(controller): decode old object for delete requests Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: modernize golang Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: modernize golang Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * chore: modernize golang Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> * fix: preserve ca-bundles injected from external providers Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: add metadata enforcement Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: add metadata enforcement Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * fix: add resourcepoolclaim validation Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * fix: add resourcepoolclaim validation Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * fix: add resourcepoolclaim validation Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: add resourcepoolclaim validation Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: security measures and prometheusrules Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: security measures and prometheusrules Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: security measures and prometheusrules Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: security measures and prometheusrules Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: security measures and prometheusrules Signed-off-by: Oliver Baehler <oliver@sudo-i.net> * feat: security measures and prometheusrules Signed-off-by: Oliver Baehler <oliver@sudo-i.net> --------- Signed-off-by: Oliver Bähler <oliverbaehler@hotmail.com> Signed-off-by: Oliver Baehler <oliver@sudo-i.net> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
52 lines
877 B
Go
52 lines
877 B
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package customquotas
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"k8s.io/apimachinery/pkg/api/resource"
|
|
)
|
|
|
|
func TestUsagePercentage(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
used string
|
|
limit string
|
|
want float64
|
|
}{
|
|
{
|
|
name: "returns zero for zero limit",
|
|
used: "1",
|
|
limit: "0",
|
|
want: 0,
|
|
},
|
|
{
|
|
name: "calculates whole quantity percentage",
|
|
used: "2",
|
|
limit: "8",
|
|
want: 25,
|
|
},
|
|
{
|
|
name: "calculates milli quantity percentage",
|
|
used: "250m",
|
|
limit: "1",
|
|
want: 25,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got := usagePercentage(resource.MustParse(tt.used), resource.MustParse(tt.limit))
|
|
if got != tt.want {
|
|
t.Fatalf("expected %v, got %v", tt.want, got)
|
|
}
|
|
})
|
|
}
|
|
}
|