Test: modified folder methods and filesystem

This commit is contained in:
HFO4
2019-12-08 10:57:43 +08:00
parent 05c802e0fa
commit 6eff13c80a
13 changed files with 135 additions and 51 deletions

View File

@@ -128,3 +128,25 @@ func TestFileSystem_IsPathExist(t *testing.T) {
}
}
func TestFileSystem_IsChildFileExist(t *testing.T) {
asserts := assert.New(t)
fs := &FileSystem{User: &model.User{
Model: gorm.Model{
ID: 1,
},
}}
folder := model.Folder{
Model: gorm.Model{ID: 1},
Name: "123",
Position: "/",
}
mock.ExpectQuery("SELECT(.+)").
WithArgs(1, "321").
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}).AddRow(2, "321"))
exist, childFile := fs.IsChildFileExist(&folder, "321")
asserts.NoError(mock.ExpectationsWereMet())
asserts.True(exist)
asserts.Equal("/123/321", childFile.Position)
}