Skip to content

Commit 4c7df56

Browse files
vishrclaude
andcommitted
Fix compilation errors in performance cookbook tests
- Remove unused encoding/json import from server.go - Fix function comparison issue in server_test.go by using needsWarmup boolean flag - Resolve "invalid operation: tt.handler == cached" error 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 1a5085e commit 4c7df56

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

cookbook/performance/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"net/http"
76
"runtime"

cookbook/performance/server_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,21 @@ func TestResponseTime(t *testing.T) {
8585
tests := []struct {
8686
name string
8787
handler echo.HandlerFunc
88+
needsWarmup bool
8889
maxDuration time.Duration
8990
description string
9091
}{
9192
{
9293
name: "fast endpoint",
9394
handler: fast,
95+
needsWarmup: false,
9496
maxDuration: 10 * time.Millisecond,
9597
description: "should respond within 10ms",
9698
},
9799
{
98100
name: "cached endpoint (after warmup)",
99101
handler: cached,
102+
needsWarmup: true,
100103
maxDuration: 50 * time.Millisecond,
101104
description: "should respond quickly from cache",
102105
},
@@ -107,7 +110,7 @@ func TestResponseTime(t *testing.T) {
107110
for _, tt := range tests {
108111
t.Run(tt.name, func(t *testing.T) {
109112
// Warm up cache if needed
110-
if tt.handler == cached {
113+
if tt.needsWarmup {
111114
req := httptest.NewRequest(http.MethodGet, "/cached", nil)
112115
rec := httptest.NewRecorder()
113116
c := e.NewContext(req, rec)

0 commit comments

Comments
 (0)