photoprism/internal/api/photos_test.go

45 lines
883 B
Go
Raw Normal View History

package api
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetPhotos(t *testing.T) {
app, router, ctx := NewApiTest()
GetPhotos(router, ctx)
2018-11-18 19:18:19 +01:00
result := PerformRequest(app, "GET", "/api/v1/photos?count=10")
assert.Equal(t, http.StatusOK, result.Code)
}
func TestLikePhoto(t *testing.T) {
app, router, ctx := NewApiTest()
LikePhoto(router, ctx)
2018-11-18 19:18:19 +01:00
result := PerformRequest(app, "POST", "/api/v1/photos/1/like")
// TODO: Test database can be empty
if result.Code != http.StatusNotFound {
assert.Equal(t, http.StatusOK, result.Code)
}
}
func TestDislikePhoto(t *testing.T) {
app, router, ctx := NewApiTest()
DislikePhoto(router, ctx)
2018-11-18 19:18:19 +01:00
result := PerformRequest(app, "DELETE", "/api/v1/photos/1/like")
// TODO: Test database can be empty
if result.Code != http.StatusNotFound {
assert.Equal(t, http.StatusOK, result.Code)
}
}