Backend: Add tests for api
This commit is contained in:
parent
b6d9d7e11f
commit
1cd2dfbd22
15
internal/api/feedback_test.go
Normal file
15
internal/api/feedback_test.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSendFeedback(t *testing.T) {
|
||||
t.Run("not available in public mode", func(t *testing.T) {
|
||||
app, router, _ := NewApiTest()
|
||||
SendFeedback(router)
|
||||
r := PerformRequestWithBody(app, "POST", "/api/v1/feedback", `{"Subject": "Send feedback from unit test", "Message": "Test message"}`)
|
||||
assert.Equal(t, 403, r.Code)
|
||||
})
|
||||
}
|
26
internal/api/file_delete_test.go
Normal file
26
internal/api/file_delete_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
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/pt9jtdre2lvl0yh7/files/ft8es39w45bnlqdw")
|
||||
assert.Equal(t, http.StatusNotFound, r.Code)
|
||||
})*/
|
||||
}
|
Loading…
Reference in a new issue