photoprism/internal/api/file_delete_test.go

36 lines
879 B
Go
Raw Normal View History

2020-10-19 16:11:42 +02:00
package api
import (
"net/http"
"testing"
2020-11-21 18:08:41 +01:00
"github.com/stretchr/testify/assert"
2020-10-19 16:11:42 +02:00
)
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)
})
2021-03-10 16:55:55 +01:00
t.Run("delete primary file", func(t *testing.T) {
2020-10-19 16:11:42 +02:00
app, router, _ := NewApiTest()
DeleteFile(router)
r := PerformRequest(app, "DELETE", "/api/v1/photos/pt9jtdre2lvl0yh7/files/ft8es39w45bnlqdw")
2021-03-10 16:55:55 +01:00
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/pt9jtdre2lvl0yh8/files/ft9es39w45bnlqdw")
2020-10-19 16:11:42 +02:00
assert.Equal(t, http.StatusNotFound, r.Code)
2021-03-10 16:55:55 +01:00
})
2020-10-19 16:11:42 +02:00
}