2020-02-02 19:40:05 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
2020-11-21 18:08:41 +01:00
|
|
|
"github.com/tidwall/gjson"
|
|
|
|
|
2020-02-02 19:40:05 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetMomentsTime(t *testing.T) {
|
2020-05-04 17:54:42 +02:00
|
|
|
t.Run("get moments time", func(t *testing.T) {
|
2020-06-25 14:54:04 +02:00
|
|
|
app, router, _ := NewApiTest()
|
2020-02-02 19:40:05 +01:00
|
|
|
|
2020-06-25 14:54:04 +02:00
|
|
|
GetMomentsTime(router)
|
2020-02-02 19:40:05 +01:00
|
|
|
|
2020-05-04 17:54:42 +02:00
|
|
|
r := PerformRequest(app, "GET", "/api/v1/moments/time")
|
2020-05-29 18:04:30 +02:00
|
|
|
val := gjson.Get(r.Body.String(), `#(Year=="2790").Count`)
|
2020-05-04 17:54:42 +02:00
|
|
|
assert.LessOrEqual(t, val.Int(), int64(2))
|
|
|
|
assert.Equal(t, http.StatusOK, r.Code)
|
2020-02-02 19:40:05 +01:00
|
|
|
})
|
|
|
|
}
|