golang-lib/web/api/status/main_test.go

37 lines
774 B
Go
Raw Normal View History

2021-06-01 10:51:35 +02:00
package status
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"dev.sum7.eu/genofire/golang-lib/web/webtest"
)
func TestAPIStatus(t *testing.T) {
assert := assert.New(t)
2021-06-28 13:59:27 +02:00
s, err := webtest.New()
assert.NoError(err)
defer s.Close()
2021-06-01 10:51:35 +02:00
assert.NotNil(s)
obj := Status{}
2021-06-23 13:39:57 +02:00
// GET
2021-06-28 13:59:27 +02:00
err = s.Request(http.MethodGet, "/api/status", nil, http.StatusOK, &obj)
2021-06-28 12:14:20 +02:00
assert.NoError(err)
2021-06-01 10:51:35 +02:00
assert.Equal(VERSION, obj.Version)
assert.Equal(EXTRAS, obj.Extras)
assert.True(obj.Up)
2021-06-23 13:39:57 +02:00
UP = func() bool { return false }
obj = Status{}
// GET - failed status
2021-06-28 12:14:20 +02:00
err = s.Request(http.MethodGet, "/api/status", nil, http.StatusInternalServerError, &obj)
assert.NoError(err)
2021-06-23 13:39:57 +02:00
assert.Equal(VERSION, obj.Version)
assert.Equal(EXTRAS, obj.Extras)
assert.False(obj.Up)
2021-06-01 10:51:35 +02:00
}