[testify-expert] Improve Test Quality: pkg/workflow/safe_outputs_config_helpers_test.go
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 73/100
Piste de recherche
Lisez pkg/workflow/safe_outputs_config_helpers_test.go en parallèle de pkg/workflow/safe_outputs_config_helpers.go ; commencez par ajouter des cas directs pour buildNormalizedSortedJSON et des cas sous forme de tableau pour buildCustomSafeOutputJobsJSON. Déplacez TestUsesPatchesAndCheckouts vers safe_outputs_runtime_test.go, comme demandé. Le travail est terminé lorsque la liste de contrôle est couverte et que make test-unit réussit.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Current State
- Test file:
pkg/workflow/safe_outputs_config_helpers_test.go(178 LOC, 3 test functions) - Source pair:
pkg/workflow/safe_outputs_config_helpers.go(61 LOC;buildNormalizedSortedJSON,buildCustomSafeOutputJobsJSON) - Note:
TestUsesPatchesAndCheckoutstargetsusesPatchesAndCheckoutsinsafe_outputs_runtime.go, not this file's source.
Strengths
- Good table-driven
TestUsesPatchesAndCheckoutscovering nil, staged (global and per-handler), and mixed cases. - Uses
requirefor preconditions andassert.JSONEqfor JSON comparison.
Prioritized Improvements
1. Missing high-value tests
buildNormalizedSortedJSONhas no direct test. Add table-driven cases: empty/nilnames; name normalization (e.g."my-job"→my_job); duplicate names that normalize to the same key (collapse to one);valueFnreceiving the normalized name; deterministic output across repeated calls.buildCustomSafeOutputJobsJSON: add a case for a single job, a job name with uppercase or special characters, and anilJobsmap vs an empty map.- Move
TestUsesPatchesAndCheckoutsintosafe_outputs_runtime_test.goto match its source file.
2. Testify assertion upgrades
Details
- In
TestBuildCustomSafeOutputJobsJSON, the trailingjson.Unmarshal+assert.Empty(result[...])is redundant withassert.JSONEq. Replace it withassert.Len(t, result, 2)or drop it.assert.Emptyon a missing key also passes, so it proves nothing. TestBuildCustomSafeOutputJobsJSONEmpty: useassert.Equal(t, "", ...)with messages, or make it table-driven.- Add messages to assertions that lack them.
3. Table-driven refactors
Details
Before:
assert.Empty(t, buildCustomSafeOutputJobsJSON(&WorkflowData{SafeOutputs: &SafeOutputsConfig{}}))
assert.Empty(t, buildCustomSafeOutputJobsJSON(&WorkflowData{SafeOutputs: nil}))
After:
tests := []struct{ name string; data *WorkflowData; want string }{
{"nil safe outputs", &WorkflowData{}, ""},
{"empty jobs", &WorkflowData{SafeOutputs: &SafeOutputsConfig{}}, ""},
{"two jobs", &WorkflowData{SafeOutputs: &SafeOutputsConfig{Jobs: map[string]*SafeJobConfig{"z-job": {}, "a-job": {}}}}, `{"a_job":"","z_job":""}`},
}
Merge TestBuildCustomSafeOutputJobsJSON and ...Empty into one table with t.Run.
4. Organization/readability
Details
- Split file by source (runtime vs config helpers).
- Consider a small helper to build a staged
BaseSafeOutputConfigto cut repeatedtemplatableBoolPtr("true")literals.
Acceptance Checklist
- Add direct tests for
buildNormalizedSortedJSON - Merge the two
buildCustomSafeOutputJobsJSONtests into one table - Remove redundant unmarshal assertions
- Move
TestUsesPatchesAndCheckoutsnext to its source -
make test-unitpasses
Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto (Claude Sonnet 5.5) · ~15 AIC · ⌖ ~1 AIC · ⊞ 9.5K · ◷
- expires on Nov 8, 2026, 10:05 AM UTC-08:00
- Langage dominant
- Go
- Étoiles
- 5.6k
- Forks
- 615
- Merge moyen
- 5 h 29 min
- PR mergées (30 j)
- 806
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Fournit un Dockerfile ou un fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/gh-aw
-
agentic-campaign automated-fix security z_campaign_security-alert-burndown
Difficulté 1/5 Moins d'une heure Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
automation cli-tools testing
Difficulté 1/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
automation cli-tools testing
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour
-
Pi on arc-dind: an aliased model reaches pi empty (`Model "aw-gateway/" not found`)Peut-être pris @pelikhan l’a pris il y a 11 jours. Ouverteai-inspected community
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
github/gh-aw#72530 · 1 réaction · 2 personnes assignées ·
Les mainteneurs répondent en général sous 1 jour
-
ai-inspected
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de github/gh-aw
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
prime-radiant-inc/evener#5901 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 69/100
-
kind/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
kyma-project/serverless#2769 ·
Les mainteneurs répondent en général sous 1 jour
-
Update the mise toolsOuverteready-for-agent
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
hexlet-basics/hexlet-basics#962 ·
Les mainteneurs répondent en général sous 1 jour
-
imapproxy closeForMaintenance grace timer calls clientConn.Close() before closeMaintenanceTransportPeut-être pris @dejanstrbac l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
Les mainteneurs répondent en général sous 1 jour