Skip to content

tests: enforce conventions for go Test#2624

Merged
zakisk merged 1 commit intotektoncd:mainfrom
chmouel:agent-update-for-tests
Mar 31, 2026
Merged

tests: enforce conventions for go Test#2624
zakisk merged 1 commit intotektoncd:mainfrom
chmouel:agent-update-for-tests

Conversation

@chmouel
Copy link
Copy Markdown
Member

@chmouel chmouel commented Mar 31, 2026

Enforce our convention on test to use table driven tests and better naming across the repository.

Add simple check in linters.yaml to enforce this. Update AGENTS.md so agents can respect it.

📝 Description of the Change

Enforces Go test conventions across the repository to improve consistency and maintainability:

  • Implemented table-driven test pattern using anonymous structs
  • Updated test naming to use PascalCase (e.g., TestGetTektonDir) with no underscores
  • Added linter rule in .tekton/linter.yaml to validate test structure compliance
  • Updated AGENTS.md with explicit test conventions and best practices for agents
  • Refactored 47 test files to comply with standards

🔗 Linked GitHub Issue

Fixes #

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

AI assistance can be used for various tasks, such as code generation,
documentation, or testing.

Please indicate whether you have used AI assistance
for this PR and provide details if applicable.

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

Important

Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.

If the majority of the code in this PR was generated by an AI, please add a `Co-authored-by` trailer to your commit message.
For example:

Co-authored-by: Claude noreply@anthropic.com

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., `fix:`, `feat:`) matches the "Type of Change" I selected above.
  • ♽ I have run `make test` and `make lint` locally to check for and fix any issues. For an efficient workflow, I have considered installing pre-commit and running `pre-commit install` to automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@chmouel chmouel force-pushed the agent-update-for-tests branch from 45f4ead to 2386c8e Compare March 31, 2026 07:44
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new linter check in .tekton/linter.yaml to enforce PascalCase naming for Go test functions and the use of the gotest.tools/v3/assert library. It updates AGENTS.md with these testing conventions and refactors numerous test files to comply by renaming functions and updating assertions. Review feedback suggests refining the linter's regex to more effectively detect underscores and identifies several instances where documentation comments were not updated to match the renamed test functions.

@chmouel chmouel force-pushed the agent-update-for-tests branch 3 times, most recently from df1ddcf to 0bbea93 Compare March 31, 2026 09:27
@chmouel
Copy link
Copy Markdown
Member Author

chmouel commented Mar 31, 2026

/test

@chmouel chmouel requested a review from zakisk March 31, 2026 09:51
@chmouel chmouel force-pushed the agent-update-for-tests branch from 0bbea93 to 75eb639 Compare March 31, 2026 10:07
Enforce our convention on test to use table driven tests and better
naming across the repository.

Add s imple check in linters.yaml to enforce this.
Update AGENTS.md so agents can respect it.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
@zakisk zakisk force-pushed the agent-update-for-tests branch from 75eb639 to 2abff06 Compare March 31, 2026 10:09
@zakisk zakisk merged commit 66bd8c2 into tektoncd:main Mar 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants