Micro & pluggable web framework for Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
903B

  1. // Copyright 2015 The Tango Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package tango
  5. import (
  6. "bytes"
  7. "net/http"
  8. "net/http/httptest"
  9. "sync"
  10. "testing"
  11. )
  12. type PoolAction struct {
  13. }
  14. func (PoolAction) Get() string {
  15. return "pool"
  16. }
  17. func TestPool(t *testing.T) {
  18. o := Classic()
  19. o.Get("/", new(PoolAction))
  20. var wg sync.WaitGroup
  21. // default pool size is 800
  22. for i := 0; i < 1000; i++ {
  23. wg.Add(1)
  24. go func() {
  25. buff := bytes.NewBufferString("")
  26. recorder := httptest.NewRecorder()
  27. recorder.Body = buff
  28. req, err := http.NewRequest("GET", "http://localhost:8000/", nil)
  29. if err != nil {
  30. t.Error(err)
  31. }
  32. o.ServeHTTP(recorder, req)
  33. expect(t, recorder.Code, http.StatusOK)
  34. refute(t, len(buff.String()), 0)
  35. expect(t, buff.String(), "pool")
  36. wg.Done()
  37. }()
  38. }
  39. wg.Wait()
  40. }