photoprism/internal/api/file_delete_test.go
Michael Mayer 713593da4e Auth: Add CLI command to create access tokens for apps #782 #808 #3943
You can now run "photoprism auth add" to create new client access tokens
that allow external applications to use the built-in REST API.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-05 16:31:07 +01:00

36 lines
879 B
Go

package api
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDeleteFile(t *testing.T) {
t.Run("delete not existing file", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteFile(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/5678/files/23456hbg")
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("delete primary file", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteFile(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh7/files/fs6sg6bw45bnlqdw")
assert.Equal(t, http.StatusInternalServerError, r.Code)
})
t.Run("try to delete file", func(t *testing.T) {
app, router, _ := NewApiTest()
DeleteFile(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/ps6sg6be2lvl0yh8/files/fs6sg6bw45bn0001")
assert.Equal(t, http.StatusNotFound, r.Code)
})
}