test(hook): NewWebdavAfterUploadHook
This commit is contained in:
parent
c5ffdbfcfb
commit
4d131db504
2 changed files with 24 additions and 1 deletions
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit ca831dbe194a6508f67bcf646a7b47c087043546
|
||||
Subproject commit 88e4b7fbf3d5e5806ad0cedce99d845ef21704c7
|
|
@ -683,3 +683,26 @@ func TestHookDeleteUploadSession(t *testing.T) {
|
|||
_, ok := cache.Get(UploadSessionCachePrefix + "TestHookDeleteUploadSession")
|
||||
a.False(ok)
|
||||
}
|
||||
func TestNewWebdavAfterUploadHook(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
fs := &FileSystem{}
|
||||
file := &fsctx.FileStream{
|
||||
Model: &model.File{
|
||||
Model: gorm.Model{ID: 1},
|
||||
},
|
||||
}
|
||||
|
||||
req, _ := http.NewRequest("get", "http://localhost", nil)
|
||||
req.Header.Add("X-Oc-Mtime", "1681521402")
|
||||
req.Header.Add("OC-Checksum", "checksum")
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)files(.+)").WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectCommit()
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)files(.+)").WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectCommit()
|
||||
err := NewWebdavAfterUploadHook(req)(context.Background(), fs, file)
|
||||
a.NoError(err)
|
||||
a.NoError(mock.ExpectationsWereMet())
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue