From 637dd739341ffeef7607b050ce7b53cd75cad54c Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Sun, 12 Apr 2026 14:27:43 +0300 Subject: [PATCH] style(api): use validation.TenantKind in test tables Replace bare "Tenant" string literals with the validation.TenantKind constant in all test table entries, struct fields, and TypeMeta. Prevents silent drift if the canonical kind string is ever renamed. Assisted-By: Claude Signed-off-by: Aleksei Sviridkin --- .../apps/application/rest_validation_test.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/registry/apps/application/rest_validation_test.go b/pkg/registry/apps/application/rest_validation_test.go index d94c501c..088990ce 100644 --- a/pkg/registry/apps/application/rest_validation_test.go +++ b/pkg/registry/apps/application/rest_validation_test.go @@ -51,14 +51,14 @@ func TestValidateNameFormat(t *testing.T) { // Tenant kind enforces alphanumeric-only — see // packages/apps/tenant/templates/_helpers.tpl for the reason. - {"tenant accepts alphanumeric", "Tenant", "foo", false}, - {"tenant accepts digits", "Tenant", "foo123", false}, - {"tenant rejects single hyphen", "Tenant", "foo-bar", true}, - {"tenant rejects leading hyphen", "Tenant", "-foo", true}, - {"tenant rejects trailing hyphen", "Tenant", "foo-", true}, - {"tenant rejects uppercase", "Tenant", "Foo", true}, - {"tenant rejects underscore", "Tenant", "foo_bar", true}, - {"tenant rejects empty", "Tenant", "", true}, + {"tenant accepts alphanumeric", validation.TenantKind, "foo", false}, + {"tenant accepts digits", validation.TenantKind, "foo123", false}, + {"tenant rejects single hyphen", validation.TenantKind, "foo-bar", true}, + {"tenant rejects leading hyphen", validation.TenantKind, "-foo", true}, + {"tenant rejects trailing hyphen", validation.TenantKind, "foo-", true}, + {"tenant rejects uppercase", validation.TenantKind, "Foo", true}, + {"tenant rejects underscore", validation.TenantKind, "foo_bar", true}, + {"tenant rejects empty", validation.TenantKind, "", true}, } for _, tt := range tests { @@ -96,7 +96,7 @@ func TestUpdate_ForceAllowCreate_RejectsTenantDashName(t *testing.T) { resourceCfg := &config.ResourceConfig{ Resources: []config.Resource{ { - Application: config.ApplicationConfig{Kind: "Tenant"}, + Application: config.ApplicationConfig{Kind: validation.TenantKind}, }, }, } @@ -116,9 +116,9 @@ func TestUpdate_ForceAllowCreate_RejectsTenantDashName(t *testing.T) { gvk: schema.GroupVersionKind{ Group: appsv1alpha1.GroupName, Version: "v1alpha1", - Kind: "Tenant", + Kind: validation.TenantKind, }, - kindName: "Tenant", + kindName: validation.TenantKind, releaseConfig: config.ReleaseConfig{ Prefix: "tenant-", }, @@ -127,7 +127,7 @@ func TestUpdate_ForceAllowCreate_RejectsTenantDashName(t *testing.T) { newApp := &appsv1alpha1.Application{ TypeMeta: metav1.TypeMeta{ APIVersion: "apps.cozystack.io/v1alpha1", - Kind: "Tenant", + Kind: validation.TenantKind, }, ObjectMeta: metav1.ObjectMeta{ Name: "foo-bar",