mirror of
https://github.com/h2non/imaginary.git
synced 2025-12-13 20:37:04 +01:00
* 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
25 lines
459 B
Go
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)
|
|
}
|
|
}
|