Add health api

This commit is contained in:
Jannis Mattheis
2019-08-11 14:09:10 +02:00
parent ad157a138b
commit 81c4a73df3
7 changed files with 197 additions and 0 deletions

6
database/ping.go Normal file
View File

@@ -0,0 +1,6 @@
package database
// Ping pings the database to verify the connection.
func (d *GormDatabase) Ping() error {
return d.DB.DB().Ping()
}

16
database/ping_test.go Normal file
View File

@@ -0,0 +1,16 @@
package database
import (
"github.com/stretchr/testify/assert"
)
func (s *DatabaseSuite) TestPing_onValidDB() {
err := s.db.Ping()
assert.NoError(s.T(), err)
}
func (s *DatabaseSuite) TestPing_onClosedDB() {
s.db.Close()
err := s.db.Ping()
assert.Error(s.T(), err)
}