httputil_test.go 778 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package httputil
  2. import (
  3. "net/http"
  4. "testing"
  5. )
  6. func TestHeaderString(t *testing.T) {
  7. h := make(http.Header)
  8. h.Add("foo", "abc")
  9. h.Add("foo", "123")
  10. h.Add("bar", "foo")
  11. h.Add("Content-Type", "application/octet-stream")
  12. s := HeaderString(h)
  13. if len(s) == 0 {
  14. t.Errorf("Header String failed to produce a valid output")
  15. return
  16. }
  17. t.Logf("Result: %s\n", s)
  18. }
  19. func TestEmptyHeader(t *testing.T) {
  20. h := make(http.Header)
  21. s := HeaderString(h)
  22. if len(s) == 0 {
  23. t.Errorf("Header String failed to produce a valid output")
  24. return
  25. }
  26. t.Logf("Result: %s\n", s)
  27. }
  28. func TestNilHeader(t *testing.T) {
  29. var h http.Header
  30. s := HeaderString(h)
  31. if len(s) == 0 {
  32. t.Errorf("Header String failed to produce a valid output")
  33. return
  34. }
  35. t.Logf("Result: %s\n", s)
  36. }