Server: Write internal server error on missing write (#57813)

This commit is contained in:
Emil Tullstedt
2022-11-07 16:14:41 +01:00
committed by GitHub
parent 6bc8ec0f9b
commit 89eba7a108
3 changed files with 32 additions and 10 deletions
+17
View File
@@ -2,8 +2,11 @@ package web
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/grafana/grafana/pkg/infra/log"
)
@@ -94,3 +97,17 @@ func TestContext_RemoteAddr(t *testing.T) {
})
}
}
func TestContext_noHandler(t *testing.T) {
recorder := httptest.NewRecorder()
method := http.MethodGet
c := &Context{
Req: httptest.NewRequest(method, "/", nil),
Resp: NewResponseWriter(method, recorder),
}
c.run()
assert.Equal(t, http.StatusInternalServerError, recorder.Code)
}