1 // Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
2 // Revel Framework source code and usage is governed by a MIT style
3 // license that can be found in the LICENSE file.
13 // Test that the render response is as expected.
14 func TestBenchmarkCompressed(t *testing.T) {
16 resp := httptest.NewRecorder()
17 c := NewTestController(resp, showRequest)
18 if err := c.SetAction("Hotels", "Show"); err != nil {
19 t.Errorf("SetAction failed: %s", err)
21 Config.SetOption("results.compressed", "true")
22 result := Hotels{c}.Show(3)
23 result.Apply(c.Request, c.Response)
24 if !strings.Contains(resp.Body.String(), "300 Main St.") {
25 t.Errorf("Failed to find hotel address in action response:\n%s", resp.Body)
29 func BenchmarkRenderCompressed(b *testing.B) {
31 resp := httptest.NewRecorder()
33 c := NewTestController(resp, showRequest)
34 if err := c.SetAction("Hotels", "Show"); err != nil {
35 b.Errorf("SetAction failed: %s", err)
37 Config.SetOption("results.compressed", "true")
41 for i := 0; i < b.N; i++ {
42 hotels.Show(3).Apply(c.Request, c.Response)
46 func BenchmarkRenderUnCompressed(b *testing.B) {
48 resp := httptest.NewRecorder()
50 c := NewTestController(resp, showRequest)
51 if err := c.SetAction("Hotels", "Show"); err != nil {
52 b.Errorf("SetAction failed: %s", err)
54 Config.SetOption("results.compressed", "false")
58 for i := 0; i < b.N; i++ {
59 hotels.Show(3).Apply(c.Request, c.Response)