From 10983e73d4d21d2d1037f9be72cd2351c4d1d24b Mon Sep 17 00:00:00 2001 From: theresa Date: Tue, 2 Mar 2021 14:59:48 +0100 Subject: [PATCH] Tests: Add tests for internal/photoprism --- internal/photoprism/mediafile_meta_test.go | 25 ++++++++++++++++++++++ internal/photoprism/photos_test.go | 13 +++++++++++ 2 files changed, 38 insertions(+) diff --git a/internal/photoprism/mediafile_meta_test.go b/internal/photoprism/mediafile_meta_test.go index 628ee762b..79eab07f9 100644 --- a/internal/photoprism/mediafile_meta_test.go +++ b/internal/photoprism/mediafile_meta_test.go @@ -46,6 +46,31 @@ func TestMediaFile_HasSidecarJson(t *testing.T) { }) } +func TestMediaFile_SidecarJsonName(t *testing.T) { + t.Run("false", func(t *testing.T) { + conf := config.TestConfig() + + mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/beach_sand.jpg") + + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, "", mediaFile.SidecarJsonName()) + }) + t.Run("true", func(t *testing.T) { + conf := config.TestConfig() + + mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/blue-go-video.mp4") + + if err != nil { + t.Fatal(err) + } + + assert.Contains(t, mediaFile.SidecarJsonName(), "blue-go-video.mp4.json") + }) +} + func TestMediaFile_NeedsExifToolJson(t *testing.T) { t.Run("false", func(t *testing.T) { conf := config.TestConfig() diff --git a/internal/photoprism/photos_test.go b/internal/photoprism/photos_test.go index f6dd866c3..5671d651f 100644 --- a/internal/photoprism/photos_test.go +++ b/internal/photoprism/photos_test.go @@ -1,7 +1,10 @@ package photoprism import ( + "github.com/photoprism/photoprism/pkg/s2" + "github.com/stretchr/testify/assert" "testing" + "time" ) func TestPhotos_Init(t *testing.T) { @@ -11,3 +14,13 @@ func TestPhotos_Init(t *testing.T) { t.Fatal(err) } } + +func TestPhotos_Find(t *testing.T) { + photos := NewPhotos() + if err := photos.Init(); err != nil { + t.Fatal(err) + } + + r := photos.Find(time.Date(2020, 11, 11, 9, 7, 18, 0, time.UTC), s2.TokenPrefix+"85d1ea7d382") + assert.Equal(t, uint(0), r) +}