Refactoring part 1: Fix some annoying linter warnings in API code (#1064)

* names, constants of reusable strings, removed unneeded `if`, replaced deprecated imports

* more deprecated imports replaced

* What is this?))

* Fix a path and quote a var in Dockerfile

* Addressing review comments

---------

Co-authored-by: Konstantin Koval <kkb@ukr.net>
This commit is contained in:
Kostiantyn
2024-09-30 15:45:02 +03:00
committed by GitHub
parent 70a3944e21
commit d1193c5ca4
38 changed files with 334 additions and 309 deletions

View File

@@ -17,7 +17,9 @@ func TestMain(m *testing.M) {
func setPathWithCurrent(paths ...string) func() {
_, file, _, ok := runtime.Caller(0)
if !ok {
return func() {}
return func() {
// Return an empty function in case of error
}
}
base := filepath.Dir(file)

View File

@@ -7,6 +7,8 @@ import (
"github.com/photoview/photoview/api/scanner/media_encoding/executable_worker"
)
const testdataBinPath = "./testdata/bin"
func TestMagickCliNotExist(t *testing.T) {
done := setPathWithCurrent()
defer done()
@@ -18,7 +20,7 @@ func TestMagickCliNotExist(t *testing.T) {
}
func TestMagickCliIgnore(t *testing.T) {
donePath := setPathWithCurrent("./testdata/bin")
donePath := setPathWithCurrent(testdataBinPath)
defer donePath()
doneDisableRaw := setEnv("PHOTOVIEW_DISABLE_RAW_PROCESSING", "true")
@@ -31,7 +33,7 @@ func TestMagickCliIgnore(t *testing.T) {
}
func TestMagickCliFail(t *testing.T) {
donePath := setPathWithCurrent("./testdata/bin")
donePath := setPathWithCurrent(testdataBinPath)
defer donePath()
executable_worker.InitializeExecutableWorkers()
@@ -53,7 +55,7 @@ func TestMagickCliFail(t *testing.T) {
}
func TestMagickCliSucceed(t *testing.T) {
donePath := setPathWithCurrent("./testdata/bin")
donePath := setPathWithCurrent(testdataBinPath)
defer donePath()
executable_worker.InitializeExecutableWorkers()