Model refactor (#3915)

* Add mockery config file
* Move basic file/folder structs to models
* Fix hack due to import loop
* Move file interfaces to models
* Move folder interfaces to models
* Move scene interfaces to models
* Move scene marker interfaces to models
* Move image interfaces to models
* Move gallery interfaces to models
* Move gallery chapter interfaces to models
* Move studio interfaces to models
* Move movie interfaces to models
* Move performer interfaces to models
* Move tag interfaces to models
* Move autotag interfaces to models
* Regenerate mocks
This commit is contained in:
DingDongSoLong4
2023-09-01 02:39:29 +02:00
committed by GitHub
parent 20520a58b4
commit c364346a59
185 changed files with 3840 additions and 2559 deletions

View File

@@ -9,13 +9,13 @@ import (
"testing"
"time"
"github.com/stashapp/stash/pkg/file"
"github.com/stashapp/stash/pkg/models"
"github.com/stretchr/testify/assert"
)
var (
invalidFolderID = file.FolderID(invalidID)
invalidFileID = file.ID(invalidID)
invalidFolderID = models.FolderID(invalidID)
invalidFileID = models.FileID(invalidID)
)
func Test_FolderStore_Create(t *testing.T) {
@@ -28,13 +28,13 @@ func Test_FolderStore_Create(t *testing.T) {
tests := []struct {
name string
newObject file.Folder
newObject models.Folder
wantErr bool
}{
{
"full",
file.Folder{
DirEntry: file.DirEntry{
models.Folder{
DirEntry: models.DirEntry{
ZipFileID: &fileIDs[fileIdxZip],
ZipFile: makeZipFileWithID(fileIdxZip),
ModTime: fileModTime,
@@ -47,7 +47,7 @@ func Test_FolderStore_Create(t *testing.T) {
},
{
"invalid parent folder id",
file.Folder{
models.Folder{
Path: path,
ParentFolderID: &invalidFolderID,
},
@@ -55,8 +55,8 @@ func Test_FolderStore_Create(t *testing.T) {
},
{
"invalid zip file id",
file.Folder{
DirEntry: file.DirEntry{
models.Folder{
DirEntry: models.DirEntry{
ZipFileID: &invalidFileID,
},
Path: path,
@@ -109,14 +109,14 @@ func Test_FolderStore_Update(t *testing.T) {
tests := []struct {
name string
updatedObject *file.Folder
updatedObject *models.Folder
wantErr bool
}{
{
"full",
&file.Folder{
&models.Folder{
ID: folderIDs[folderIdxWithParentFolder],
DirEntry: file.DirEntry{
DirEntry: models.DirEntry{
ZipFileID: &fileIDs[fileIdxZip],
ZipFile: makeZipFileWithID(fileIdxZip),
ModTime: fileModTime,
@@ -129,7 +129,7 @@ func Test_FolderStore_Update(t *testing.T) {
},
{
"clear zip",
&file.Folder{
&models.Folder{
ID: folderIDs[folderIdxInZip],
Path: path,
},
@@ -137,7 +137,7 @@ func Test_FolderStore_Update(t *testing.T) {
},
{
"clear folder",
&file.Folder{
&models.Folder{
ID: folderIDs[folderIdxWithParentFolder],
Path: path,
},
@@ -145,7 +145,7 @@ func Test_FolderStore_Update(t *testing.T) {
},
{
"invalid parent folder id",
&file.Folder{
&models.Folder{
ID: folderIDs[folderIdxWithParentFolder],
Path: path,
ParentFolderID: &invalidFolderID,
@@ -154,9 +154,9 @@ func Test_FolderStore_Update(t *testing.T) {
},
{
"invalid zip file id",
&file.Folder{
&models.Folder{
ID: folderIDs[folderIdxWithParentFolder],
DirEntry: file.DirEntry{
DirEntry: models.DirEntry{
ZipFileID: &invalidFileID,
},
Path: path,
@@ -192,7 +192,7 @@ func Test_FolderStore_Update(t *testing.T) {
}
}
func makeFolderWithID(index int) *file.Folder {
func makeFolderWithID(index int) *models.Folder {
ret := makeFolder(index)
ret.ID = folderIDs[index]
@@ -207,7 +207,7 @@ func Test_FolderStore_FindByPath(t *testing.T) {
tests := []struct {
name string
path string
want *file.Folder
want *models.Folder
wantErr bool
}{
{