Files
imaginary_mirror/error_test.go
Tom 384bb00b15 New release, minor features, bimg upgrade and several fixes (#311)
* feat: add fly.io

* feat(readme): fly image width

* feat(readme): add html image + badge

* fix(docs): try space non-URL encoding

* Update README.md

* Update README.md

* Update README.md

* feat(docs): add fly.io info and links

* feat(#305, #309, #308, #305. #284)

* fix(ci): golinter

* fix(Dockerfile): use root folder for go test / ci linter

* fix(ci): allow to fail  go 1.14 build, still not sure why

* fix(ci): bad yaml format

* fix(ci): use travis-compatible regex

* fix(ci): lets skip go1.14 for now

* fix(mod): update dependencies
2020-06-07 18:38:14 +02:00

25 lines
459 B
Go

package main
import "testing"
func TestDefaultError(t *testing.T) {
err := NewError("oops!\n\n", 503)
if err.Error() != "oops!" {
t.Fatal("Invalid error message")
}
if err.Code != 503 {
t.Fatal("Invalid error code")
}
code := err.HTTPCode()
if code != 503 {
t.Fatalf("Invalid HTTP error status: %d", code)
}
json := string(err.JSON())
if json != "{\"message\":\"oops!\",\"status\":503}" {
t.Fatalf("Invalid JSON output: %s", json)
}
}