Skip to content

Commit ea4a490

Browse files
committed
chore(claude): prefer map pattern table tests
1 parent e4e01dc commit ea4a490

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

.claude/CLAUDE.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,29 +133,29 @@ func NewExampleCommand(clients *shared.ClientFactory) *cobra.Command {
133133

134134
### Table-Driven Test Conventions
135135

136-
**Preferred: Slice pattern** - uses `tc` for test case variable:
136+
**Preferred: Map pattern** - uses `tc` for test case variable:
137137
```go
138-
tests := []struct {
139-
name string
138+
tests := map[string]struct {
140139
input string
141140
expected string
142141
}{...}
143-
for _, tc := range tests {
144-
t.Run(tc.name, func(t *testing.T) {
142+
for name, tc := range tests {
143+
t.Run(name, func(t *testing.T) {
145144
// use tc.field
146145
})
147146
}
148147
```
149148

150-
**Legacy: Map pattern** - uses `tt` for test case variable (do not use for new tests):
149+
**Legacy: Slice pattern** - uses `tc` for test case variable (do not use for new tests):
151150
```go
152-
tests := map[string]struct {
151+
tests := []struct {
152+
name string
153153
input string
154154
expected string
155155
}{...}
156-
for name, tt := range tests {
157-
t.Run(name, func(t *testing.T) {
158-
// use tt.field
156+
for _, tc := range tests {
157+
t.Run(tc.name, func(t *testing.T) {
158+
// use tc.field
159159
})
160160
}
161161
```

0 commit comments

Comments
 (0)