API: Query database from /api/health endpoint (#28349)

This commit is contained in:
Emil Hessman
2020-10-21 11:06:19 +02:00
committed by GitHub
parent 9fce64c6aa
commit 13e67660f5
5 changed files with 234 additions and 4 deletions
+2 -1
View File
@@ -10,5 +10,6 @@ func init() {
}
func GetDBHealthQuery(query *models.GetDBHealthQuery) error {
return x.Ping()
_, err := x.Exec("SELECT 1")
return err
}
+18
View File
@@ -0,0 +1,18 @@
// +build integration
package sqlstore
import (
"testing"
"github.com/grafana/grafana/pkg/models"
"github.com/stretchr/testify/require"
)
func TestGetDBHealthQuery(t *testing.T) {
InitTestDB(t)
query := models.GetDBHealthQuery{}
err := GetDBHealthQuery(&query)
require.NoError(t, err)
}