photoprism/internal/api/files_test.go
Michael Mayer f5a8c5a45d Auth: Session and ACL enhancements #98 #1746
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-09-28 09:01:17 +02:00

28 lines
729 B
Go

package api
import (
"net/http"
"testing"
"github.com/tidwall/gjson"
"github.com/stretchr/testify/assert"
)
func TestGetFile(t *testing.T) {
t.Run("search for existing file", func(t *testing.T) {
app, router, _ := NewApiTest()
GetFile(router)
r := PerformRequest(app, "GET", "/api/v1/files/2cad9168fa6acc5c5c2965ddf6ec465ca42fd818")
assert.Equal(t, http.StatusOK, r.Code)
val := gjson.Get(r.Body.String(), "Name")
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", val.String())
})
t.Run("search for not existing file", func(t *testing.T) {
app, router, _ := NewApiTest()
GetFile(router)
r := PerformRequest(app, "GET", "/api/v1/files/111")
assert.Equal(t, http.StatusNotFound, r.Code)
})
}