mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 17:41:57 +08:00
fix: keep update at column when rename
This commit is contained in:
@@ -3,11 +3,12 @@ package filesystem
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response"
|
||||
testMock "github.com/stretchr/testify/mock"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response"
|
||||
testMock "github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
model "github.com/cloudreve/Cloudreve/v3/models"
|
||||
"github.com/cloudreve/Cloudreve/v3/pkg/cache"
|
||||
@@ -670,8 +671,8 @@ func TestFileSystem_Rename(t *testing.T) {
|
||||
WithArgs(10, 1).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}).AddRow(10, "old.text"))
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)files(.+)").
|
||||
WithArgs("new.txt", sqlmock.AnyArg(), 10).
|
||||
mock.ExpectExec("UPDATE(.+)files(.+)SET(.+)").
|
||||
WithArgs("new.txt", 10).
|
||||
WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectCommit()
|
||||
err := fs.Rename(ctx, []uint{}, []uint{10}, "new.txt")
|
||||
@@ -696,8 +697,8 @@ func TestFileSystem_Rename(t *testing.T) {
|
||||
WithArgs(10, 1).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}).AddRow(10, "old.text"))
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)files(.+)").
|
||||
WithArgs("new.txt", sqlmock.AnyArg(), 10).
|
||||
mock.ExpectExec("UPDATE(.+)files(.+)SET(.+)").
|
||||
WithArgs("new.txt", 10).
|
||||
WillReturnError(errors.New("error"))
|
||||
mock.ExpectRollback()
|
||||
err := fs.Rename(ctx, []uint{}, []uint{10}, "new.txt")
|
||||
@@ -712,8 +713,8 @@ func TestFileSystem_Rename(t *testing.T) {
|
||||
WithArgs(10, 1).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}).AddRow(10, "old"))
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)folders(.+)").
|
||||
WithArgs("new", sqlmock.AnyArg(), 10).
|
||||
mock.ExpectExec("UPDATE(.+)folders(.+)SET(.+)").
|
||||
WithArgs("new", 10).
|
||||
WillReturnResult(sqlmock.NewResult(1, 1))
|
||||
mock.ExpectCommit()
|
||||
err := fs.Rename(ctx, []uint{10}, []uint{}, "new")
|
||||
@@ -738,8 +739,8 @@ func TestFileSystem_Rename(t *testing.T) {
|
||||
WithArgs(10, 1).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}).AddRow(10, "old"))
|
||||
mock.ExpectBegin()
|
||||
mock.ExpectExec("UPDATE(.+)folders(.+)").
|
||||
WithArgs("new", sqlmock.AnyArg(), 10).
|
||||
mock.ExpectExec("UPDATE(.+)folders(.+)SET(.+)").
|
||||
WithArgs("new", 10).
|
||||
WillReturnError(errors.New("error"))
|
||||
mock.ExpectRollback()
|
||||
err := fs.Rename(ctx, []uint{10}, []uint{}, "new")
|
||||
|
||||
Reference in New Issue
Block a user