jsonmessage_test.go 476 B

123456789101112131415161718192021222324
  1. package utils
  2. import (
  3. "testing"
  4. )
  5. func TestError(t *testing.T) {
  6. je := JSONError{404, "Not found"}
  7. if je.Error() != "Not found" {
  8. t.Fatalf("Expected 'Not found' got '%s'", je.Error())
  9. }
  10. }
  11. func TestProgress(t *testing.T) {
  12. jp := JSONProgress{0, 0, 0}
  13. if jp.String() != "" {
  14. t.Fatalf("Expected empty string, got '%s'", jp.String())
  15. }
  16. jp2 := JSONProgress{1, 0, 0}
  17. if jp2.String() != " 1 B/?" {
  18. t.Fatalf("Expected ' 1/?', got '%s'", jp2.String())
  19. }
  20. }