Files
capsule/pkg/template/functions/funcmap_age_test.go
T
Oliver Bähler da74cfdab7 fix: allow replications to own replications without blocking controller updates (#2107)
* chore

* perfromance improvements

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* perfromance improvements

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat(performance): removed duplicate client calls from all admission paths

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add globalresourcequota api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add globalresourcequota api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add globalresourcequota api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add globalresourcequota api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add globalresourcequota api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* feat: add globalresourcequota api

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* fix: remove resource rejections checks

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* fix: allow replications to own replications without blocking controller updates

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* fix: allow replications to own replications without blocking controller updates

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

* fix: allow replications to own replications without blocking controller updates

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>

---------

Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
2026-08-26 21:59:57 +02:00

71 lines
1.6 KiB
Go

// Copyright 2020-2026 Project Capsule Authors
// SPDX-License-Identifier: Apache-2.0
package functions
import "testing"
func TestFuncMaps(t *testing.T) {
t.Parallel()
custom := CustomFuncMap()
for _, name := range []string{
"toToml",
"fromToml",
"fromYamlArray",
"fromJsonArray",
"deterministicUUID",
"generateAgeKey",
"generateAgePQKey",
"getResourceByName",
"mustGetResourceByName",
"getResourceByNamespacedName",
} {
if custom[name] == nil {
t.Fatalf("CustomFuncMap()[%q] is nil", name)
}
}
extra := ExtraFuncMap()
if extra["env"] != nil || extra["expandEnv"] != nil {
t.Fatalf("ExtraFuncMap() should remove unsafe env functions")
}
if extra["generateAgeKey"] == nil {
t.Fatalf("ExtraFuncMap() missing custom function")
}
}
func TestFromYAMLArray(t *testing.T) {
t.Parallel()
got := fromYAMLArray("- a\n- b\n")
if len(got) != 2 || got[0] != "a" || got[1] != "b" {
t.Fatalf("fromYAMLArray() = %#v", got)
}
got = fromYAMLArray(":\n")
if len(got) != 1 {
t.Fatalf("fromYAMLArray(invalid) = %#v, want single error item", got)
}
}
func TestGenerateAgeKeys(t *testing.T) {
t.Parallel()
key, ok := generateAgeKey().(AgeKeyPair)
if !ok {
t.Fatalf("generateAgeKey() did not return AgeKeyPair")
}
if key.Identity == "" || key.Recipient == "" {
t.Fatalf("generateAgeKey() = %#v, want identity and recipient", key)
}
pqKey, ok := generateAgePQKey().(AgeKeyPair)
if !ok {
t.Fatalf("generateAgePQKey() did not return AgeKeyPair")
}
if pqKey.Identity == "" || pqKey.Recipient == "" {
t.Fatalf("generateAgePQKey() = %#v, want identity and recipient", pqKey)
}
}