photoprism/internal/entity/query/lens_test.go
Keith Martin c3eda657fd
Metadata: Add Lens Make and Model updates via CLI & API #5644 #5656
Adds the ability to override a lens's Make/Model (e.g. fixing Pentax lenses that ExifTool decodes as `4 38`) via a new photoprism lenses update CLI command and a `PUT /api/v1/lenses/:id endpoint`, plus a `GET /api/v1/lenses` search endpoint, a new lenses ACL resource, and an lenses ls list command.
2026-06-15 09:37:32 +02:00

39 lines
1.1 KiB
Go

package query
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/internal/entity"
)
func TestFindLensBySlug(t *testing.T) {
t.Run("ExistingLens", func(t *testing.T) {
lens := FindLensBySlug(entity.LensFixtures.Get("4.15mm-f/2.2").LensSlug)
assert.NotNil(t, lens)
if lens != nil {
assert.Equal(t, entity.LensFixtures.Get("4.15mm-f/2.2").ID, lens.ID)
assert.Equal(t, entity.LensFixtures.Get("4.15mm-f/2.2").LensModel, lens.LensModel)
}
})
t.Run("NotExistingLens", func(t *testing.T) {
lens := FindLensBySlug("IAmNotValid")
assert.Nil(t, lens)
})
}
func TestFindLensByID(t *testing.T) {
t.Run("ExistingLens", func(t *testing.T) {
lens := FindLensByID(entity.LensFixtures.Get("4.15mm-f/2.2").ID)
assert.NotNil(t, lens)
if lens != nil {
assert.Equal(t, entity.LensFixtures.Get("4.15mm-f/2.2").ID, lens.ID)
assert.Equal(t, entity.LensFixtures.Get("4.15mm-f/2.2").LensModel, lens.LensModel)
}
})
t.Run("NotExistingLens", func(t *testing.T) {
lens := FindLensByID(99885541348)
assert.Nil(t, lens)
})
}