31e48d2139
Note this is disabled in public mode (without authentication).
28 lines
665 B
Go
28 lines
665 B
Go
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")
|
|
// Ok if no error is thrown.
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
|
})
|
|
}
|
|
|
|
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)
|
|
})
|
|
}
|