Add unit tests for name generation, data transformation, and object helpers

Abierto
#76 1 comentario 0 reacciones 0 asignados Ver en GitHub

@VISHNU0906 ya está trabajando en esto.

Desde el 11/11/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
72/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
go
Área
backend, testing

Línea de trabajo

Comienza con las funciones indicadas en internal/controller/devportal_helper.go, internal/controller/apikey_secret_controller.go, los archivos de tipos de api/v1alpha1 y los reconcilers. Lee cada función y añade cobertura de pruebas unitarias para los casos normales, límite, de ramificación, de mutación y de round-trip descritos en el issue. Ejecuta make test; el trabajo está terminado cuando todas las funciones solicitadas están cubiertas y la suite de pruebas pasa.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement good first issue triage/accepted

Summary

Write unit tests for the pure functions that generate deterministic names, transform data between types, and manage object annotations. All testable without envtest.

Testing Guidance

For each function, think about:

  • What does it return for normal, expected input?
  • What happens at the boundaries — empty strings, nil objects, missing fields?
  • If there's branching logic, have you covered each branch?

Scope

internal/controller/devportal_helper.go
  • APIKeyRequestName() — generates a DNS-1123 compliant name from an APIKey using a SHA-256 hash suffix. Think about: does the output meet DNS-1123 rules? Is it deterministic (same input = same output)? Different namespace/name combinations that could collide without the hash.
internal/controller/apikey_secret_controller.go
  • enforcementSecretName() — same pattern as above, generates a deterministic name for enforcement secrets. Same considerations apply.
api/v1alpha1/apikey_types.go
  • APIProductKey() — returns an ObjectKey for the referenced APIProduct, falling back to the APIKey's own namespace if the ref namespace is empty. Test the fallback behaviour.
api/v1alpha1/apikeyrequest_types.go
  • ClientObject() — converts an APIKeyReference to an ObjectKey. Straightforward struct conversion.
api/v1alpha1/apiproduct_types.go
  • PlanPolicyIntoPlans() — converts a PlanPolicy's plan list into PlanSpec slice. Test with nil input, empty plan list, and multiple plans.
internal/controller/apiproduct_controller.go
  • extractIssuerURLFromAuthScheme() — finds the first JWT issuer URL from an auth scheme. Consider: no authentication map, authentication with non-JWT entries, multiple JWT entries (which one wins?), nil auth scheme.
internal/controller/apikeyrequest_controller.go
  • apiKeyRequestSpecMutator() — compares existing vs desired specs, mutates existing if different, returns whether mutation occurred. Test: specs are equal (no mutation), specs differ (mutation happens), verify the existing object is actually updated.
internal/reconcilers/base_reconcilers.go
  • TagObjectToDelete() / IsObjectTaggedToDelete() — adds/checks a deletion annotation. Test: object with no annotations, object with existing annotations, round-trip (tag then check).

Review & Verification

PRs should include:

  • How to review the changes (areas of interest, suggested review order)
  • Steps to confirm locally: make test runs and passes
Lenguaje dominante
Go
Estrellas
3
Forks
15
Merge medio
1 d 21 h
PR fusionados (30 d)
4

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Kuadrant/developer-portal-controller

Todos los issues de Kuadrant/developer-portal-controller

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.