package pages
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
// TestAPIMessageMirrorsMessage keeps the two registers on one table: a status
// that has a sentence for a reader must have a word for a parser, or a REST
// surface silently falls back to its own spelling.
func TestAPIMessageMirrorsMessage(t *testing.T) {
for _, status := range []int{
http.StatusUnauthorized, http.StatusForbidden, http.StatusNotFound,
http.StatusMethodNotAllowed, http.StatusInternalServerError,
http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout,
} {
assert.NotEmpty(t, Message(status), "page sentence for %d", status)
assert.NotEmpty(t, APIMessage(status), "machine word for %d", status)
assert.NotEqual(t, Message(status), APIMessage(status),
"%d: a parser and a reader are not the same audience", status)
}
assert.Empty(t, APIMessage(http.StatusTeapot))
assert.Equal(t, "not found", APIMessage(http.StatusNotFound))
}