2017-08-20 03:52:42 +05:30
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2020-01-02 02:12:45 +05:30
|
|
|
"io/ioutil"
|
|
|
|
"net/http/httptest"
|
2017-08-20 03:52:42 +05:30
|
|
|
"testing"
|
|
|
|
|
|
|
|
testify "github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2020-01-02 02:12:45 +05:30
|
|
|
func TestConfig_NotFound(t *testing.T) {
|
2017-08-20 03:52:42 +05:30
|
|
|
assert := testify.New(t)
|
2019-04-28 03:13:22 +05:30
|
|
|
|
2020-01-02 02:12:45 +05:30
|
|
|
req := httptest.NewRequest("GET", "http://example.com", nil)
|
|
|
|
w := httptest.NewRecorder()
|
2019-04-28 03:13:22 +05:30
|
|
|
|
2020-01-02 02:12:45 +05:30
|
|
|
NotFound(w, req)
|
2019-04-28 03:13:22 +05:30
|
|
|
|
2020-01-02 02:12:45 +05:30
|
|
|
resp := w.Result()
|
|
|
|
assert.Equal(404, resp.StatusCode)
|
|
|
|
assert.Equal("application/json", resp.Header.Get("Content-Type"))
|
|
|
|
response, _ := ioutil.ReadAll(resp.Body)
|
|
|
|
assert.JSONEq(`{
|
|
|
|
"status": "404",
|
|
|
|
"message": "Not Found"
|
|
|
|
}`, string(response))
|
2019-04-28 03:13:22 +05:30
|
|
|
}
|