body := strings.NewReader("") 7 req := httptest.NewRequest(method, target, body) 8 req.Header.Set("X-USER-ID", userID) 9 rec := httptest.NewRecorder() 1 func TestCustomHandler(t *testing.T) { 2 t.Run("Add userID", func(t *testing.T) { 3 userID := "12345678" 10 11 e := initEcho() 12 e.ServeHTTP(rec, req) 13 14 ctx := e.AcquireContext() 15 defer e.ReleaseContext(ctx) 16 c := GetContextValues(ctx) 17 res := rec.Result() 18 assert.Equal(t, 200, res.StatusCode) 19 assert.Equal(t, userID, rec.Body.String()) 20 assert.Equal(t, userID, c.UserID) 21 }) 22 }