From e673003181e18e38313935d4861326c0b52c9b41 Mon Sep 17 00:00:00 2001 From: Bob <241886672+bob12224@users.noreply.github.com> Date: Tue, 28 Apr 2026 19:23:29 -0700 Subject: [PATCH] Fixing linter upgrade --- docs/DEVELOPMENT.md | 4 +-- pkg/audio/export_test.go | 37 +++++++++------------------ pkg/audio/import_test.go | 20 --------------- pkg/audio/scan.go | 8 +++--- pkg/audio/scan_test.go | 2 -- pkg/audio/update_test.go | 8 ------ pkg/file/audio/caption_test.go | 22 ++++++++-------- pkg/models/mocks/AudioReaderWriter.go | 14 ---------- 8 files changed, 29 insertions(+), 86 deletions(-) diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 6ed1f25b2..a8e204c12 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -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) diff --git a/pkg/audio/export_test.go b/pkg/audio/export_test.go index bdaad0a95..c2cb290b0 100644 --- a/pkg/audio/export_test.go +++ b/pkg/audio/export_test.go @@ -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) { diff --git a/pkg/audio/import_test.go b/pkg/audio/import_test.go index 7c37374ae..78edc153b 100644 --- a/pkg/audio/import_test.go +++ b/pkg/audio/import_test.go @@ -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() diff --git a/pkg/audio/scan.go b/pkg/audio/scan.go index 17e473b0e..f1cf0b224 100644 --- a/pkg/audio/scan.go +++ b/pkg/audio/scan.go @@ -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 diff --git a/pkg/audio/scan_test.go b/pkg/audio/scan_test.go index 3254d1ac5..550a66c17 100644 --- a/pkg/audio/scan_test.go +++ b/pkg/audio/scan_test.go @@ -1,5 +1,3 @@ -// TODO(audio): update this file - package audio import ( diff --git a/pkg/audio/update_test.go b/pkg/audio/update_test.go index 5d34ceb0e..2738ea13e 100644 --- a/pkg/audio/update_test.go +++ b/pkg/audio/update_test.go @@ -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 ) diff --git a/pkg/file/audio/caption_test.go b/pkg/file/audio/caption_test.go index 199e18053..37a28db55 100644 --- a/pkg/file/audio/caption_test.go +++ b/pkg/file/audio/caption_test.go @@ -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 }, } diff --git a/pkg/models/mocks/AudioReaderWriter.go b/pkg/models/mocks/AudioReaderWriter.go index 705445a81..c6271f7e4 100644 --- a/pkg/models/mocks/AudioReaderWriter.go +++ b/pkg/models/mocks/AudioReaderWriter.go @@ -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)