util_test.go 833 B

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