2020-07-07 17:18:11 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetErrors(t *testing.T) {
|
|
|
|
t.Run("successful request", func(t *testing.T) {
|
|
|
|
app, router, _ := NewApiTest()
|
|
|
|
GetErrors(router)
|
|
|
|
r := PerformRequest(app, "GET", "/api/v1/errors")
|
2022-04-03 12:37:43 +02:00
|
|
|
// Ok if no error is thrown.
|
2020-07-07 17:18:11 +02:00
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
|
|
})
|
|
|
|
}
|
2022-04-03 12:37:43 +02:00
|
|
|
|
|
|
|
func TestDeleteErrors(t *testing.T) {
|
|
|
|
t.Run("successful request", func(t *testing.T) {
|
|
|
|
app, router, _ := NewApiTest()
|
|
|
|
DeleteErrors(router)
|
|
|
|
r := PerformRequest(app, "DELETE", "/api/v1/errors")
|
|
|
|
// Disabled in public mode, so error 403 is expected.
|
|
|
|
assert.Equal(t, http.StatusForbidden, r.Code)
|
|
|
|
})
|
|
|
|
}
|