mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Model refactor, part 3 (#4152)
* Remove manager.Repository * Refactor other repositories * Fix tests and add database mock * Add AssertExpectations method * Refactor routes * Move default movie image to internal/static and add convenience methods * Refactor default performer image boxes
This commit is contained in:
@@ -130,19 +130,19 @@ var getStudioScenarios = []stringTestScenario{
|
||||
}
|
||||
|
||||
func TestGetStudioName(t *testing.T) {
|
||||
mockStudioReader := &mocks.StudioReaderWriter{}
|
||||
db := mocks.NewDatabase()
|
||||
|
||||
studioErr := errors.New("error getting image")
|
||||
|
||||
mockStudioReader.On("Find", testCtx, studioID).Return(&models.Studio{
|
||||
db.Studio.On("Find", testCtx, studioID).Return(&models.Studio{
|
||||
Name: studioName,
|
||||
}, nil).Once()
|
||||
mockStudioReader.On("Find", testCtx, missingStudioID).Return(nil, nil).Once()
|
||||
mockStudioReader.On("Find", testCtx, errStudioID).Return(nil, studioErr).Once()
|
||||
db.Studio.On("Find", testCtx, missingStudioID).Return(nil, nil).Once()
|
||||
db.Studio.On("Find", testCtx, errStudioID).Return(nil, studioErr).Once()
|
||||
|
||||
for i, s := range getStudioScenarios {
|
||||
image := s.input
|
||||
json, err := GetStudioName(testCtx, mockStudioReader, &image)
|
||||
json, err := GetStudioName(testCtx, db.Studio, &image)
|
||||
|
||||
switch {
|
||||
case !s.err && err != nil:
|
||||
@@ -154,5 +154,5 @@ func TestGetStudioName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
mockStudioReader.AssertExpectations(t)
|
||||
db.AssertExpectations(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user