Skip to content

docs(agent): add table-driven test want structuring rules to go-coding-rule.md - #1173

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-lzrzmkmvopkk
Oct 23, 2026
Merged

kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-lzrzmkmvopkk

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 23, 2026

Copy link
Copy Markdown
Member

Summary

Updates .agents/rules/go-coding-rule.md under ## Testing Practices to document how want fields should be structured in table-driven tests:

  • Never Derive want from Inputs in the Test Loop: Every expected value must be declared explicitly as a literal in the test case table rather than computed from input fields inside the for _, tc := range testCases body (e.g., wantMounted := !tc.jobMode).
  • Whole-Struct want for Data Outputs: When testing a function that returns a struct or multiple data values, define a single want ReturnType (or local outcome struct) and compare it with cmp.Diff(tc.want, got) rather than splitting fields into wantLen, wantStart, wantEnd, etc.
  • Multiple Side Effects or Staged Assertions: When verifying multiple independent side effects or using an early expectation to gate subsequent setup, keep all expected values in the table case definition.
@kyasbal kyasbal added the type:docs Improvements or additions to documentation label Oct 23, 2026
@kyasbal
kyasbal requested a review from renamoo as a code owner October 23, 2026 07:55
@kyasbal kyasbal added the area:agent AI agent skills, rules, and prompt workflows label Oct 23, 2026
@kyasbal
kyasbal requested a review from K53 as a code owner October 23, 2026 07:55
@kyasbal kyasbal added type:docs Improvements or additions to documentation area:agent AI agent skills, rules, and prompt workflows labels Oct 23, 2026

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

Copy link
Copy Markdown
Contributor

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 updates the Go coding rules in .agents/rules/go-coding-rule.md to include guidelines and anti-patterns for structuring want values in table-driven tests. The feedback suggests a minor phrasing improvement to clarify that expected and actual values are compared using cmp.Diff rather than compared with it.

Comment thread .agents/rules/go-coding-rule.md Resolved
@kyasbal
kyasbal added this pull request to the merge queue Oct 23, 2026
Merged via the queue into GoogleCloudPlatform:main with commit ca3cc88 Oct 23, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-lzrzmkmvopkk branch October 23, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent AI agent skills, rules, and prompt workflows type:docs Improvements or additions to documentation

1 participant