From b0798823542ce473f6cc38632722505cf30040d4 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 29 Apr 2019 20:09:10 +0200 Subject: [PATCH] Slow test refactoring (now using testing.Short()) --- internal/photoprism/colors_test.go | 105 ++++++++++---------- internal/photoprism/converter_slow_test.go | 104 ------------------- internal/photoprism/converter_test.go | 102 +++++++++++++++++++ internal/photoprism/exif_slow_test.go | 28 ------ internal/photoprism/exif_test.go | 22 ++++ internal/photoprism/importer_slow_test.go | 25 ----- internal/photoprism/importer_test.go | 20 ++++ internal/photoprism/mediafile_slow_test.go | 42 -------- internal/photoprism/mediafile_test.go | 36 +++++++ internal/photoprism/tensorflow_slow_test.go | 36 ------- internal/photoprism/tensorflow_test.go | 29 ++++++ internal/photoprism/thumbnails_slow_test.go | 31 ------ internal/photoprism/thumbnails_test.go | 26 +++++ 13 files changed, 289 insertions(+), 317 deletions(-) delete mode 100644 internal/photoprism/converter_slow_test.go delete mode 100644 internal/photoprism/exif_slow_test.go delete mode 100644 internal/photoprism/importer_slow_test.go delete mode 100644 internal/photoprism/mediafile_slow_test.go delete mode 100644 internal/photoprism/tensorflow_slow_test.go delete mode 100644 internal/photoprism/thumbnails_slow_test.go diff --git a/internal/photoprism/colors_test.go b/internal/photoprism/colors_test.go index f6153b9e8..017c472a8 100644 --- a/internal/photoprism/colors_test.go +++ b/internal/photoprism/colors_test.go @@ -12,67 +12,70 @@ func TestMediaFile_GetColors(t *testing.T) { conf.InitializeTestData(t) - if mediaFile1, err := NewMediaFile(conf.ImportPath() + "/dog.jpg"); err == nil { - colors, main, l, s, err := mediaFile1.Colors() + t.Run("dog.jpg", func(t *testing.T) { + if mediaFile, err := NewMediaFile(conf.ImportPath() + "/dog.jpg"); err == nil { + colors, main, l, s, err := mediaFile.Colors() - t.Log(colors, main, l, s, err) + t.Log(colors, main, l, s, err) - assert.Nil(t, err) - assert.Equal(t, 2, s.Int()) - assert.IsType(t, MaterialColors{}, colors) - assert.Equal(t, "grey", main.Name()) - assert.Equal(t, MaterialColors{0x1, 0x2, 0x1, 0x2, 0x2, 0x1, 0x1, 0x1, 0x0}, colors) - assert.Equal(t, LightMap{5, 9, 7, 10, 9, 5, 5, 6, 2}, l) - } else { - t.Error(err) - } + assert.Nil(t, err) + assert.Equal(t, 2, s.Int()) + assert.IsType(t, MaterialColors{}, colors) + assert.Equal(t, "grey", main.Name()) + assert.Equal(t, MaterialColors{0x1, 0x2, 0x1, 0x2, 0x2, 0x1, 0x1, 0x1, 0x0}, colors) + assert.Equal(t, LightMap{5, 9, 7, 10, 9, 5, 5, 6, 2}, l) + } else { + t.Error(err) + } + }) - if mediaFile2, err := NewMediaFile(conf.ImportPath() + "/ape.jpeg"); err == nil { - colors, main, l, s, err := mediaFile2.Colors() + t.Run("ape.jpeg", func(t *testing.T) { + if mediaFile, err := NewMediaFile(conf.ImportPath() + "/ape.jpeg"); err == nil { + colors, main, l, s, err := mediaFile.Colors() - t.Log(colors, main, l, s, err) + t.Log(colors, main, l, s, err) - assert.Nil(t, err) - assert.Equal(t, 3, s.Int()) - assert.IsType(t, MaterialColors{}, colors) - assert.Equal(t, "teal", main.Name()) - assert.Equal(t, MaterialColors{0x8, 0x8, 0x2, 0x8, 0x2, 0x1, 0x8, 0x1, 0x2}, colors) - assert.Equal(t, LightMap{8, 8, 7, 7, 7, 5, 8, 6, 8}, l) - } else { - t.Error(err) - } + assert.Nil(t, err) + assert.Equal(t, 3, s.Int()) + assert.IsType(t, MaterialColors{}, colors) + assert.Equal(t, "teal", main.Name()) + assert.Equal(t, MaterialColors{0x8, 0x8, 0x2, 0x8, 0x2, 0x1, 0x8, 0x1, 0x2}, colors) + assert.Equal(t, LightMap{8, 8, 7, 7, 7, 5, 8, 6, 8}, l) + } else { + t.Error(err) + } + }) - if testing.Short() { - return - } + t.Run("iphone/IMG_6788.JPG", func(t *testing.T) { + if mediaFile, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err == nil { + colors, main, l, s, err := mediaFile.Colors() - if mediaFile2, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err == nil { - colors, main, l, s, err := mediaFile2.Colors() + t.Log(colors, main, l, s, err) - t.Log(colors, main, l, s, err) + assert.Nil(t, err) + assert.Equal(t, 3, s.Int()) + assert.IsType(t, MaterialColors{}, colors) + assert.Equal(t, "grey", main.Name()) + assert.Equal(t, MaterialColors{0x2, 0x1, 0x2, 0x1, 0x1, 0x1, 0x2, 0x1, 0x2}, colors) + } else { + t.Error(err) + } + }) - assert.Nil(t, err) - assert.Equal(t, 3, s.Int()) - assert.IsType(t, MaterialColors{}, colors) - assert.Equal(t, "grey", main.Name()) - assert.Equal(t, MaterialColors{0x2, 0x1, 0x2, 0x1, 0x1, 0x1, 0x2, 0x1, 0x2}, colors) - } else { - t.Error(err) - } + t.Run("raw/20140717_154212_1EC48F8489.jpg", func(t *testing.T) { + if mediaFile, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"); err == nil { + colors, main, l, s, err := mediaFile.Colors() - if mediaFile3, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"); err == nil { - colors, main, l, s, err := mediaFile3.Colors() + t.Log(colors, main, l, s, err) - t.Log(colors, main, l, s, err) + assert.Nil(t, err) + assert.Equal(t, 2, s.Int()) + assert.IsType(t, MaterialColors{}, colors) + assert.Equal(t, "grey", main.Name()) - assert.Nil(t, err) - assert.Equal(t, 2, s.Int()) - assert.IsType(t, MaterialColors{}, colors) - assert.Equal(t, "grey", main.Name()) - - assert.Equal(t, MaterialColors{0x3, 0x2, 0x2, 0x1, 0x2, 0x2, 0x2, 0x2, 0x1}, colors) - - } else { - t.Error(err) - } + assert.Equal(t, MaterialColors{0x3, 0x2, 0x2, 0x1, 0x2, 0x2, 0x2, 0x2, 0x1}, colors) + } else { + t.Error(err) + } + }) } diff --git a/internal/photoprism/converter_slow_test.go b/internal/photoprism/converter_slow_test.go deleted file mode 100644 index 0295cbd84..000000000 --- a/internal/photoprism/converter_slow_test.go +++ /dev/null @@ -1,104 +0,0 @@ -// +build slow - -package photoprism - -import ( - "os" - "testing" - - "github.com/photoprism/photoprism/internal/fsutil" - "github.com/photoprism/photoprism/internal/test" - "github.com/stretchr/testify/assert" -) - -func TestConverter_ConvertToJpeg(t *testing.T) { - conf := test.NewConfig() - - conf.InitializeTestData(t) - - converter := NewConverter(conf.DarktableCli()) - - jpegFilename := conf.ImportPath() + "/iphone/IMG_6788.JPG" - - assert.Truef(t, fsutil.Exists(jpegFilename), "file does not exist: %s", jpegFilename) - - t.Logf("Testing RAW to JPEG converter with %s", jpegFilename) - - jpegMediaFile, err := NewMediaFile(jpegFilename) - - assert.Nil(t, err) - - imageJpeg, err := converter.ConvertToJpeg(jpegMediaFile) - - assert.Empty(t, err, "ConvertToJpeg() failed") - - infoJpeg, err := imageJpeg.GetExifData() - - assert.Emptyf(t, err, "GetExifData() failed") - - assert.Equal(t, jpegFilename, imageJpeg.filename) - - assert.False(t, infoJpeg == nil || err != nil, "Could not read EXIF data of JPEG image") - - assert.Equal(t, "iPhone SE", infoJpeg.CameraModel) - - rawFilemame := conf.ImportPath() + "/raw/IMG_1435.CR2" - - t.Logf("Testing RAW to JPEG converter with %s", rawFilemame) - - rawMediaFile, err := NewMediaFile(rawFilemame) - - assert.Nil(t, err) - - imageRaw, _ := converter.ConvertToJpeg(rawMediaFile) - - assert.True(t, fsutil.Exists(conf.ImportPath()+"/raw/IMG_1435.jpg"), "Jpeg file was not found - is Darktable installed?") - - assert.NotEqual(t, rawFilemame, imageRaw.filename) - - infoRaw, err := imageRaw.GetExifData() - - assert.False(t, infoRaw == nil || err != nil, "Could not read EXIF data of RAW image") - - assert.Equal(t, "Canon EOS M10", infoRaw.CameraModel) -} - -func TestConverter_ConvertAll(t *testing.T) { - conf := test.NewConfig() - - conf.InitializeTestData(t) - - converter := NewConverter(conf.DarktableCli()) - - converter.ConvertAll(conf.ImportPath()) - - jpegFilename := conf.ImportPath() + "/raw/IMG_1435.jpg" - - assert.True(t, fsutil.Exists(jpegFilename), "Jpeg file was not found - is Darktable installed?") - - image, err := NewMediaFile(jpegFilename) - - assert.Nil(t, err) - - assert.Equal(t, jpegFilename, image.filename, "FileName must be the same") - - infoRaw, err := image.GetExifData() - - assert.False(t, infoRaw == nil || err != nil, "Could not read EXIF data of RAW image") - - assert.Equal(t, "Canon EOS M10", infoRaw.CameraModel, "Camera model should be Canon EOS M10") - - existingJpegFilename := conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg" - - oldHash := fsutil.Hash(existingJpegFilename) - - os.Remove(existingJpegFilename) - - converter.ConvertAll(conf.ImportPath()) - - newHash := fsutil.Hash(existingJpegFilename) - - assert.True(t, fsutil.Exists(existingJpegFilename), "Jpeg file was not found - is Darktable installed?") - - assert.NotEqual(t, oldHash, newHash, "Fingerprint of old and new JPEG file must not be the same") -} diff --git a/internal/photoprism/converter_test.go b/internal/photoprism/converter_test.go index 54b08c4f2..6f65d0dfb 100644 --- a/internal/photoprism/converter_test.go +++ b/internal/photoprism/converter_test.go @@ -1,8 +1,10 @@ package photoprism import ( + "os" "testing" + "github.com/photoprism/photoprism/internal/fsutil" "github.com/photoprism/photoprism/internal/test" "github.com/stretchr/testify/assert" ) @@ -14,3 +16,103 @@ func TestNewConverter(t *testing.T) { assert.IsType(t, &Converter{}, converter) } + +func TestConverter_ConvertToJpeg(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.InitializeTestData(t) + + converter := NewConverter(conf.DarktableCli()) + + jpegFilename := conf.ImportPath() + "/iphone/IMG_6788.JPG" + + assert.Truef(t, fsutil.Exists(jpegFilename), "file does not exist: %s", jpegFilename) + + t.Logf("Testing RAW to JPEG converter with %s", jpegFilename) + + jpegMediaFile, err := NewMediaFile(jpegFilename) + + assert.Nil(t, err) + + imageJpeg, err := converter.ConvertToJpeg(jpegMediaFile) + + assert.Empty(t, err, "ConvertToJpeg() failed") + + infoJpeg, err := imageJpeg.GetExifData() + + assert.Emptyf(t, err, "GetExifData() failed") + + assert.Equal(t, jpegFilename, imageJpeg.filename) + + assert.False(t, infoJpeg == nil || err != nil, "Could not read EXIF data of JPEG image") + + assert.Equal(t, "iPhone SE", infoJpeg.CameraModel) + + rawFilemame := conf.ImportPath() + "/raw/IMG_1435.CR2" + + t.Logf("Testing RAW to JPEG converter with %s", rawFilemame) + + rawMediaFile, err := NewMediaFile(rawFilemame) + + assert.Nil(t, err) + + imageRaw, _ := converter.ConvertToJpeg(rawMediaFile) + + assert.True(t, fsutil.Exists(conf.ImportPath()+"/raw/IMG_1435.jpg"), "Jpeg file was not found - is Darktable installed?") + + assert.NotEqual(t, rawFilemame, imageRaw.filename) + + infoRaw, err := imageRaw.GetExifData() + + assert.False(t, infoRaw == nil || err != nil, "Could not read EXIF data of RAW image") + + assert.Equal(t, "Canon EOS M10", infoRaw.CameraModel) +} + +func TestConverter_ConvertAll(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.InitializeTestData(t) + + converter := NewConverter(conf.DarktableCli()) + + converter.ConvertAll(conf.ImportPath()) + + jpegFilename := conf.ImportPath() + "/raw/IMG_1435.jpg" + + assert.True(t, fsutil.Exists(jpegFilename), "Jpeg file was not found - is Darktable installed?") + + image, err := NewMediaFile(jpegFilename) + + assert.Nil(t, err) + + assert.Equal(t, jpegFilename, image.filename, "FileName must be the same") + + infoRaw, err := image.GetExifData() + + assert.False(t, infoRaw == nil || err != nil, "Could not read EXIF data of RAW image") + + assert.Equal(t, "Canon EOS M10", infoRaw.CameraModel, "Camera model should be Canon EOS M10") + + existingJpegFilename := conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg" + + oldHash := fsutil.Hash(existingJpegFilename) + + os.Remove(existingJpegFilename) + + converter.ConvertAll(conf.ImportPath()) + + newHash := fsutil.Hash(existingJpegFilename) + + assert.True(t, fsutil.Exists(existingJpegFilename), "Jpeg file was not found - is Darktable installed?") + + assert.NotEqual(t, oldHash, newHash, "Fingerprint of old and new JPEG file must not be the same") +} diff --git a/internal/photoprism/exif_slow_test.go b/internal/photoprism/exif_slow_test.go deleted file mode 100644 index 3c24b6956..000000000 --- a/internal/photoprism/exif_slow_test.go +++ /dev/null @@ -1,28 +0,0 @@ -// +build slow - -package photoprism - -import ( - "testing" - - "github.com/photoprism/photoprism/internal/test" - "github.com/stretchr/testify/assert" -) - -func TestMediaFile_GetExifData_Slow(t *testing.T) { - conf := test.NewConfig() - - conf.InitializeTestData(t) - - image2, err := NewMediaFile(conf.ImportPath() + "/raw/IMG_1435.CR2") - - assert.Nil(t, err) - - info, err := image2.GetExifData() - - assert.Empty(t, err) - - assert.IsType(t, &ExifData{}, info) - - assert.Equal(t, "Canon EOS M10", info.CameraModel) -} diff --git a/internal/photoprism/exif_test.go b/internal/photoprism/exif_test.go index 30aaffe00..ccb3229d9 100644 --- a/internal/photoprism/exif_test.go +++ b/internal/photoprism/exif_test.go @@ -24,3 +24,25 @@ func TestMediaFile_GetExifData(t *testing.T) { assert.Equal(t, "iPhone SE", info.CameraModel) } + +func TestMediaFile_GetExifData_Slow(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.InitializeTestData(t) + + image2, err := NewMediaFile(conf.ImportPath() + "/raw/IMG_1435.CR2") + + assert.Nil(t, err) + + info, err := image2.GetExifData() + + assert.Empty(t, err) + + assert.IsType(t, &ExifData{}, info) + + assert.Equal(t, "Canon EOS M10", info.CameraModel) +} diff --git a/internal/photoprism/importer_slow_test.go b/internal/photoprism/importer_slow_test.go deleted file mode 100644 index 056338642..000000000 --- a/internal/photoprism/importer_slow_test.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build slow - -package photoprism - -import ( - "testing" - - "github.com/photoprism/photoprism/internal/test" -) - -func TestImporter_ImportPhotosFromDirectory(t *testing.T) { - conf := test.NewConfig() - - conf.InitializeTestData(t) - - tensorFlow := NewTensorFlow(conf.TensorFlowModelPath()) - - indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db()) - - converter := NewConverter(conf.DarktableCli()) - - importer := NewImporter(conf.OriginalsPath(), indexer, converter) - - importer.ImportPhotosFromDirectory(conf.ImportPath()) -} diff --git a/internal/photoprism/importer_test.go b/internal/photoprism/importer_test.go index ca7d51e7e..c7501fd29 100644 --- a/internal/photoprism/importer_test.go +++ b/internal/photoprism/importer_test.go @@ -43,3 +43,23 @@ func TestImporter_GetDestinationFilename(t *testing.T) { assert.Equal(t, conf.OriginalsPath()+"/2018/02/20180204_170813_863A6248DCCA.cr2", filename) } + +func TestImporter_ImportPhotosFromDirectory(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.InitializeTestData(t) + + tensorFlow := NewTensorFlow(conf.TensorFlowModelPath()) + + indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db()) + + converter := NewConverter(conf.DarktableCli()) + + importer := NewImporter(conf.OriginalsPath(), indexer, converter) + + importer.ImportPhotosFromDirectory(conf.ImportPath()) +} diff --git a/internal/photoprism/mediafile_slow_test.go b/internal/photoprism/mediafile_slow_test.go deleted file mode 100644 index 2e8bc2395..000000000 --- a/internal/photoprism/mediafile_slow_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// +build slow - -package photoprism - -import ( - "testing" - - "github.com/photoprism/photoprism/internal/test" - "github.com/stretchr/testify/assert" -) - -func TestMediaFile_GetPerceptiveHash_Slow(t *testing.T) { - conf := test.NewConfig() - - conf.InitializeTestData(t) - - mediaFile1, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280.jpg") - assert.Nil(t, err) - hash1, _ := mediaFile1.GetPerceptualHash() - - assert.Equal(t, "ef95", hash1) - - mediaFile2, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280_V2.jpg") - assert.Nil(t, err) - hash2, _ := mediaFile2.GetPerceptualHash() - - assert.Equal(t, "6f95", hash2) - - distance, _ := mediaFile1.GetPerceptualDistance(hash2) - - assert.Equal(t, 1, distance) - - mediaFile3, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG") - assert.Nil(t, err) - hash3, _ := mediaFile3.GetPerceptualHash() - - assert.Equal(t, "ad73", hash3) - - distance, _ = mediaFile1.GetPerceptualDistance(hash3) - - assert.Equal(t, 7, distance) -} diff --git a/internal/photoprism/mediafile_test.go b/internal/photoprism/mediafile_test.go index 94dbbb75f..8d7ddc325 100644 --- a/internal/photoprism/mediafile_test.go +++ b/internal/photoprism/mediafile_test.go @@ -120,3 +120,39 @@ func TestMediaFile_Exists(t *testing.T) { assert.NotNil(t, err) assert.Nil(t, mediaFile) } + +func TestMediaFile_GetPerceptiveHash_Slow(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.InitializeTestData(t) + + mediaFile1, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280.jpg") + assert.Nil(t, err) + hash1, _ := mediaFile1.GetPerceptualHash() + + assert.Equal(t, "ef95", hash1) + + mediaFile2, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280_V2.jpg") + assert.Nil(t, err) + hash2, _ := mediaFile2.GetPerceptualHash() + + assert.Equal(t, "6f95", hash2) + + distance, _ := mediaFile1.GetPerceptualDistance(hash2) + + assert.Equal(t, 1, distance) + + mediaFile3, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG") + assert.Nil(t, err) + hash3, _ := mediaFile3.GetPerceptualHash() + + assert.Equal(t, "ad73", hash3) + + distance, _ = mediaFile1.GetPerceptualDistance(hash3) + + assert.Equal(t, 7, distance) +} diff --git a/internal/photoprism/tensorflow_slow_test.go b/internal/photoprism/tensorflow_slow_test.go deleted file mode 100644 index eb87a915a..000000000 --- a/internal/photoprism/tensorflow_slow_test.go +++ /dev/null @@ -1,36 +0,0 @@ -// +build slow - -package photoprism - -import ( - "io/ioutil" - "math" - "testing" - - "github.com/photoprism/photoprism/internal/test" - "github.com/stretchr/testify/assert" -) - -func TestTensorFlow_GetImageTags(t *testing.T) { - conf := test.NewConfig() - - conf.InitializeTestData(t) - - tensorFlow := NewTensorFlow(conf.TensorFlowModelPath()) - - if imageBuffer, err := ioutil.ReadFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err != nil { - t.Error(err) - } else { - result, err := tensorFlow.GetImageTags(string(imageBuffer)) - - assert.NotNil(t, result) - assert.Nil(t, err) - assert.IsType(t, []TensorFlowLabel{}, result) - assert.Equal(t, 5, len(result)) - - assert.Equal(t, "tabby", result[0].Label) - assert.Equal(t, "tiger cat", result[1].Label) - - assert.Equal(t, float64(0.165), math.Round(float64(result[1].Probability)*1000)/1000) - } -} diff --git a/internal/photoprism/tensorflow_test.go b/internal/photoprism/tensorflow_test.go index 3cdd3d2f3..21b8a6996 100644 --- a/internal/photoprism/tensorflow_test.go +++ b/internal/photoprism/tensorflow_test.go @@ -1,6 +1,7 @@ package photoprism import ( + "io/ioutil" "math" "testing" @@ -27,3 +28,31 @@ func TestTensorFlow_GetImageTagsFromFile(t *testing.T) { assert.Equal(t, float64(0.165), math.Round(float64(result[1].Probability)*1000)/1000) } + +func TestTensorFlow_GetImageTags(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.InitializeTestData(t) + + tensorFlow := NewTensorFlow(conf.TensorFlowModelPath()) + + if imageBuffer, err := ioutil.ReadFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err != nil { + t.Error(err) + } else { + result, err := tensorFlow.GetImageTags(string(imageBuffer)) + + assert.NotNil(t, result) + assert.Nil(t, err) + assert.IsType(t, []TensorFlowLabel{}, result) + assert.Equal(t, 5, len(result)) + + assert.Equal(t, "tabby", result[0].Label) + assert.Equal(t, "tiger cat", result[1].Label) + + assert.Equal(t, float64(0.165), math.Round(float64(result[1].Probability)*1000)/1000) + } +} diff --git a/internal/photoprism/thumbnails_slow_test.go b/internal/photoprism/thumbnails_slow_test.go deleted file mode 100644 index a56e5c36a..000000000 --- a/internal/photoprism/thumbnails_slow_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// +build slow - -package photoprism - -import ( - "testing" - - "github.com/photoprism/photoprism/internal/test" -) - -func TestCreateThumbnailsFromOriginals(t *testing.T) { - conf := test.NewConfig() - - conf.CreateDirectories() - - conf.InitializeTestData(t) - - tensorFlow := NewTensorFlow(conf.TensorFlowModelPath()) - - indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db()) - - converter := NewConverter(conf.DarktableCli()) - - importer := NewImporter(conf.OriginalsPath(), indexer, converter) - - importer.ImportPhotosFromDirectory(conf.ImportPath()) - - CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.ThumbnailsPath(), 600, false) - - CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.ThumbnailsPath(), 300, true) -} diff --git a/internal/photoprism/thumbnails_test.go b/internal/photoprism/thumbnails_test.go index ebfff0b17..d529c4c2d 100644 --- a/internal/photoprism/thumbnails_test.go +++ b/internal/photoprism/thumbnails_test.go @@ -40,3 +40,29 @@ func TestMediaFile_GetSquareThumbnail(t *testing.T) { assert.IsType(t, &MediaFile{}, thumbnail1) } + +func TestCreateThumbnailsFromOriginals(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + conf := test.NewConfig() + + conf.CreateDirectories() + + conf.InitializeTestData(t) + + tensorFlow := NewTensorFlow(conf.TensorFlowModelPath()) + + indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db()) + + converter := NewConverter(conf.DarktableCli()) + + importer := NewImporter(conf.OriginalsPath(), indexer, converter) + + importer.ImportPhotosFromDirectory(conf.ImportPath()) + + CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.ThumbnailsPath(), 600, false) + + CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.ThumbnailsPath(), 300, true) +}