From 562f74ac2146e5a16fb54a3cd9fdd6896e12be79 Mon Sep 17 00:00:00 2001 From: theresa Date: Tue, 21 Sep 2021 11:04:43 +0200 Subject: [PATCH] Tests: Add unit tests --- internal/search/photos_geo_test.go | 102 +++++++++++++++++++++++++++++ internal/search/photos_test.go | 102 +++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) diff --git a/internal/search/photos_geo_test.go b/internal/search/photos_geo_test.go index 91b7c20b0..88f4cde0a 100644 --- a/internal/search/photos_geo_test.go +++ b/internal/search/photos_geo_test.go @@ -414,4 +414,106 @@ func TestGeo(t *testing.T) { assert.True(t, r.PhotoFavorite) } }) + t.Run("keywords:kuh|bridge > keywords:bridge&kuh", func(t *testing.T) { + var f form.PhotoSearchGeo + f.Query = "keywords:kuh|bridge" + + photos, err := PhotosGeo(f) + + if err != nil { + t.Fatal(err) + } + + f.Query = "keywords:bridge&kuh" + + photos2, err2 := PhotosGeo(f) + + if err2 != nil { + t.Fatal(err2) + } + + assert.Greater(t, len(photos), len(photos2)) + }) + t.Run("albums and and or search", func(t *testing.T) { + var f form.PhotoSearchGeo + f.Query = "albums:Holiday|Berlin" + + photos, err := PhotosGeo(f) + + if err != nil { + t.Fatal(err) + } + + f.Query = "albums:Berlin&Holiday" + + photos2, err2 := PhotosGeo(f) + + if err2 != nil { + t.Fatal(err2) + } + assert.Greater(t, len(photos), len(photos2)) + }) + t.Run("people and and or search", func(t *testing.T) { + var f form.PhotoSearchGeo + f.People = "Actor A|Actress A" + + photos, err := PhotosGeo(f) + + if err != nil { + t.Fatal(err) + } + + f.People = "Actor A&Actress A" + + photos2, err2 := PhotosGeo(f) + + if err2 != nil { + t.Fatal(err2) + } + + assert.Greater(t, len(photos), len(photos2)) + }) + t.Run("people = subjects & person = subject", func(t *testing.T) { + var f form.PhotoSearchGeo + f.People = "Actor" + + photos, err := PhotosGeo(f) + + if err != nil { + t.Fatal(err) + } + var f2 form.PhotoSearchGeo + + f2.Subjects = "Actor" + + photos2, err2 := PhotosGeo(f2) + + if err2 != nil { + t.Fatal(err2) + } + + assert.Equal(t, len(photos), len(photos2)) + + var f3 form.PhotoSearchGeo + + f3.Person = "Actor A" + + photos3, err3 := PhotosGeo(f3) + + if err3 != nil { + t.Fatal(err3) + } + + var f4 form.PhotoSearchGeo + f4.Subject = "Actor A" + + photos4, err4 := PhotosGeo(f4) + + if err4 != nil { + t.Fatal(err4) + } + + assert.Equal(t, len(photos3), len(photos4)) + assert.Equal(t, len(photos), len(photos4)) + }) } diff --git a/internal/search/photos_test.go b/internal/search/photos_test.go index 2d949c4be..6c616c394 100644 --- a/internal/search/photos_test.go +++ b/internal/search/photos_test.go @@ -1133,4 +1133,106 @@ func TestPhotos(t *testing.T) { assert.GreaterOrEqual(t, len(photos), 2) }) + t.Run("keywords:kuh|bridge > keywords:bridge&kuh", func(t *testing.T) { + var f form.PhotoSearch + f.Query = "keywords:kuh|bridge" + + photos, _, err := Photos(f) + + if err != nil { + t.Fatal(err) + } + + f.Query = "keywords:bridge&kuh" + + photos2, _, err2 := Photos(f) + + if err2 != nil { + t.Fatal(err2) + } + + assert.Greater(t, len(photos), len(photos2)) + }) + t.Run("albums and and or search", func(t *testing.T) { + var f form.PhotoSearch + f.Query = "albums:Holiday|Berlin" + + photos, _, err := Photos(f) + + if err != nil { + t.Fatal(err) + } + + f.Query = "albums:Berlin&Holiday" + + photos2, _, err2 := Photos(f) + + if err2 != nil { + t.Fatal(err2) + } + assert.Greater(t, len(photos), len(photos2)) + }) + t.Run("people and and or search", func(t *testing.T) { + var f form.PhotoSearch + f.People = "Actor A|Actress A" + + photos, _, err := Photos(f) + + if err != nil { + t.Fatal(err) + } + + f.People = "Actor A&Actress A" + + photos2, _, err2 := Photos(f) + + if err2 != nil { + t.Fatal(err2) + } + + assert.Greater(t, len(photos), len(photos2)) + }) + t.Run("people = subjects & person = subject", func(t *testing.T) { + var f form.PhotoSearch + f.People = "Actor" + + photos, _, err := Photos(f) + + if err != nil { + t.Fatal(err) + } + var f2 form.PhotoSearch + + f2.Subjects = "Actor" + + photos2, _, err2 := Photos(f2) + + if err2 != nil { + t.Fatal(err2) + } + + assert.Equal(t, len(photos), len(photos2)) + + var f3 form.PhotoSearch + + f3.Person = "Actor A" + + photos3, _, err3 := Photos(f3) + + if err3 != nil { + t.Fatal(err3) + } + + var f4 form.PhotoSearch + f4.Subject = "Actor A" + + photos4, _, err4 := Photos(f4) + + if err4 != nil { + t.Fatal(err4) + } + + assert.Equal(t, len(photos3), len(photos4)) + assert.Equal(t, len(photos), len(photos4)) + }) }