support_test.go 764 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package builder
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func TestSelectAcceptableMIME(t *testing.T) {
  7. validMimeStrings := []string{
  8. "application/x-bzip2",
  9. "application/bzip2",
  10. "application/gzip",
  11. "application/x-gzip",
  12. "application/x-xz",
  13. "application/xz",
  14. "application/tar",
  15. "application/x-tar",
  16. "application/octet-stream",
  17. "text/plain",
  18. }
  19. invalidMimeStrings := []string{
  20. "",
  21. "application/octet",
  22. "application/json",
  23. }
  24. for _, m := range invalidMimeStrings {
  25. if len(selectAcceptableMIME(m)) > 0 {
  26. err := fmt.Errorf("Should not have accepted %q", m)
  27. t.Fatal(err)
  28. }
  29. }
  30. for _, m := range validMimeStrings {
  31. if str := selectAcceptableMIME(m); str == "" {
  32. err := fmt.Errorf("Should have accepted %q", m)
  33. t.Fatal(err)
  34. }
  35. }
  36. }