From 098255c7414f521ab84dd033a46b866d0533e568 Mon Sep 17 00:00:00 2001 From: graciousgrey Date: Thu, 27 Jul 2023 16:09:23 +0200 Subject: [PATCH] Tests: Add unit tests #2596 --- internal/search/photos_test.go | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/internal/search/photos_test.go b/internal/search/photos_test.go index 1b7c475a7..4d77c2448 100644 --- a/internal/search/photos_test.go +++ b/internal/search/photos_test.go @@ -666,6 +666,50 @@ func TestPhotos(t *testing.T) { } assert.LessOrEqual(t, 2, len(photos)) + }) + t.Run("Latmin:33.45343166666667 Latmax:49.519234", func(t *testing.T) { + var f form.SearchPhotos + f.Query = "Latmin:33.45343166666667 Latmax:49.519234" + f.Count = 10 + f.Offset = 0 + f.Order = "imported" + + photos, _, err := Photos(f) + + if err != nil { + t.Fatal(err) + } + + for _, p := range photos { + assert.GreaterOrEqual(t, float32(49.519234), p.PhotoLat) + assert.LessOrEqual(t, float32(33.45343166666667), p.PhotoLat) + } + + assert.LessOrEqual(t, 2, len(photos)) + + }) + t.Run("Latmin:0.00 Latmax:49.519234 Lngmin:-30.123 Lngmax:9.1001234", func(t *testing.T) { + var f form.SearchPhotos + f.Query = "Latmin:0.00 Latmax:49.519234 Lngmin:-30.123 Lngmax:9.1001234" + f.Count = 10 + f.Offset = 0 + f.Order = "imported" + + photos, _, err := Photos(f) + + if err != nil { + t.Fatal(err) + } + + for _, p := range photos { + assert.GreaterOrEqual(t, float32(49.519234), p.PhotoLat) + assert.LessOrEqual(t, float32(0.00), p.PhotoLat) + assert.GreaterOrEqual(t, float32(9.1001234), p.PhotoLng) + assert.LessOrEqual(t, float32(-30.123), p.PhotoLng) + } + + assert.LessOrEqual(t, 10, len(photos)) + }) t.Run("form.Before and form.After Order:relevance", func(t *testing.T) { var f form.SearchPhotos