Fixing linter upgrade

This commit is contained in:
Bob 2026-04-28 19:23:29 -07:00
parent 1a6d23a622
commit e673003181
8 changed files with 29 additions and 86 deletions

View file

@ -3,10 +3,10 @@
## Pre-requisites
* [Go](https://golang.org/dl/)
* Version 1.24.* (v1.26.x is unable to run the linter)
* Version 1.25.*
* [GolangCI](https://golangci-lint.run/) - A meta-linter which runs several linters in parallel
* To install, follow the [local installation instructions](https://golangci-lint.run/welcome/install/#local-installation)
* Install v1, NOT v2
* Install v2.11.4
* [nodejs](https://nodejs.org/en/download) - nodejs runtime
* corepack/[pnpm](https://pnpm.io/installation) - nodejs package manager (included with nodejs)

View file

@ -1,5 +1,3 @@
// TODO(audio): update this file
package audio
import (
@ -17,9 +15,7 @@ import (
)
const (
audioID = 1
noImageID = 2
errImageID = 3
audioID = 1
studioID = 4
missingStudioID = 5
@ -66,8 +62,7 @@ var names = []string{
}
const (
path = "path"
imageBase64 = "aW1hZ2VCeXRlcw=="
path = "path"
)
var (
@ -119,7 +114,7 @@ func createEmptyAudio(id int) models.Audio {
}
}
func createFullJSONAudio(image string, customFields map[string]interface{}) *jsonschema.Audio {
func createFullJSONAudio(customFields map[string]interface{}) *jsonschema.Audio {
return &jsonschema.Audio{
Title: title,
Files: []string{path},
@ -134,7 +129,6 @@ func createFullJSONAudio(image string, customFields map[string]interface{}) *jso
UpdatedAt: json.JSONTime{
Time: updateTime,
},
Cover: image,
CustomFields: customFields,
}
}
@ -164,34 +158,27 @@ var scenarios = []basicTestScenario{
{
createFullAudio(audioID),
emptyCustomFields,
createFullJSONAudio(imageBase64, emptyCustomFields),
createFullJSONAudio(emptyCustomFields),
false,
},
{
createFullAudio(customFieldsID),
customFields,
createFullJSONAudio("", customFields),
false,
},
{
createEmptyAudio(noImageID),
emptyCustomFields,
createEmptyJSONAudio(),
false,
},
{
createFullAudio(errImageID),
emptyCustomFields,
createFullJSONAudio("", emptyCustomFields),
// failure to get image should not cause an error
createFullJSONAudio(customFields),
false,
},
{
createFullAudio(errCustomFieldsID),
customFields,
createFullJSONAudio("", customFields),
createFullJSONAudio(customFields),
true,
},
{
createEmptyAudio(audioID),
emptyCustomFields,
createEmptyJSONAudio(),
false,
},
}
func TestToJSON(t *testing.T) {

View file

@ -1,5 +1,3 @@
// TODO(audio): update this file
package audio
import (
@ -17,8 +15,6 @@ import (
"github.com/stretchr/testify/mock"
)
const invalidImage = "aW1hZ2VCeXRlcw&&"
var (
existingStudioID = 101
existingPerformerID = 103
@ -173,22 +169,6 @@ func TestImporterPreImportHistory(t *testing.T) {
}
}
func TestImporterPreImportCoverImage(t *testing.T) {
i := Importer{
Input: jsonschema.Audio{
Cover: invalidImage,
},
}
err := i.PreImport(testCtx)
assert.NotNil(t, err)
i.Input.Cover = imageBase64
err = i.PreImport(testCtx)
assert.Nil(t, err)
}
func TestImporterPreImportWithStudio(t *testing.T) {
db := mocks.NewDatabase()

View file

@ -54,19 +54,19 @@ type ScanHandler struct {
func (h *ScanHandler) validate() error {
if h.CreatorUpdater == nil {
return errors.New("CreatorUpdater is required")
return errors.New("internal error:CreatorUpdater is required")
}
// if h.ScanGenerator == nil {
// return errors.New("ScanGenerator is required")
// }
if h.CaptionUpdater == nil {
return errors.New("CaptionUpdater is required")
return errors.New("internal error:CaptionUpdater is required")
}
if !h.FileNamingAlgorithm.IsValid() {
return errors.New("FileNamingAlgorithm is required")
return errors.New("internal error:FileNamingAlgorithm is required")
}
if h.Paths == nil {
return errors.New("Paths is required")
return errors.New("internal error:Paths is required")
}
return nil

View file

@ -1,5 +1,3 @@
// TODO(audio): update this file
package audio
import (

View file

@ -1,5 +1,3 @@
// TODO(audio): update this file
package audio
import (
@ -77,7 +75,6 @@ func TestUpdater_Update(t *testing.T) {
badUpdateID
badPerformersID
badTagsID
badCoverID
performerID
tagID
)
@ -86,7 +83,6 @@ func TestUpdater_Update(t *testing.T) {
tagIDs := []int{tagID}
title := "title"
cover := []byte("cover")
validAudio := &models.Audio{}
@ -99,9 +95,6 @@ func TestUpdater_Update(t *testing.T) {
}), mock.Anything).Return(validAudio, nil)
db.Audio.On("UpdatePartial", testCtx, badUpdateID, mock.Anything).Return(nil, updateErr)
db.Audio.On("UpdateCover", testCtx, audioID, cover).Return(nil).Once()
db.Audio.On("UpdateCover", testCtx, badCoverID, cover).Return(updateErr).Once()
tests := []struct {
name string
u *UpdateSet
@ -179,7 +172,6 @@ func TestUpdateSet_UpdateInput(t *testing.T) {
badUpdateID
badPerformersID
badTagsID
badCoverID
performerID
tagID
)

View file

@ -1,4 +1,4 @@
// TODO(audio): update this file
// TODO(audio): Can this file be deleted if we utilize audioCaptions?
package audio
import (
@ -15,29 +15,29 @@ type testCase struct {
var testCases = []testCase{
{
captionPath: "/stash/video.vtt",
captionPath: "/stash/audio.vtt",
expectedLang: LangUnknown,
expectedResult: "/stash/video.",
expectedResult: "/stash/audio.",
},
{
captionPath: "/stash/video.en.vtt",
captionPath: "/stash/audio.en.vtt",
expectedLang: "en",
expectedResult: "/stash/video.", // lang code valid, remove en part
expectedResult: "/stash/audio.", // lang code valid, remove en part
},
{
captionPath: "/stash/video.test.srt",
captionPath: "/stash/audio.test.srt",
expectedLang: LangUnknown,
expectedResult: "/stash/video.test.", // no lang code/lang code invalid test should remain
expectedResult: "/stash/audio.test.", // no lang code/lang code invalid test should remain
},
{
captionPath: "C:\\videos\\video.fr.srt",
captionPath: "C:\\audios\\audio.fr.srt",
expectedLang: "fr",
expectedResult: "C:\\videos\\video.",
expectedResult: "C:\\audios\\audio.",
},
{
captionPath: "C:\\videos\\video.xx.srt",
captionPath: "C:\\audios\\audio.xx.srt",
expectedLang: LangUnknown,
expectedResult: "C:\\videos\\video.xx.", // no lang code/lang code invalid xx should remain
expectedResult: "C:\\audios\\audio.xx.", // no lang code/lang code invalid xx should remain
},
}

View file

@ -1344,20 +1344,6 @@ func (_m *AudioReaderWriter) Update(ctx context.Context, updatedAudio *models.Au
return r0
}
// UpdateCover provides a mock function with given fields: ctx, audioID, cover
func (_m *AudioReaderWriter) UpdateCover(ctx context.Context, audioID int, cover []byte) error {
ret := _m.Called(ctx, audioID, cover)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, int, []byte) error); ok {
r0 = rf(ctx, audioID, cover)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdatePartial provides a mock function with given fields: ctx, id, updatedAudio
func (_m *AudioReaderWriter) UpdatePartial(ctx context.Context, id int, updatedAudio models.AudioPartial) (*models.Audio, error) {
ret := _m.Called(ctx, id, updatedAudio)