Skip to content

Commit

Permalink
Tests: Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
graciousgrey committed Apr 2, 2022
1 parent 946e617 commit d7f4c46
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/entity/photo_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ var PhotoFixtures = PhotoMap{
TakenSrc: "",
PhotoType: "image",
TypeSrc: "",
PhotoTitle: "",
PhotoTitle: "Lake / 2001",
TitleSrc: "",
PhotoDescription: "",
DescriptionSrc: "",
Expand Down
38 changes: 32 additions & 6 deletions internal/search/photos_filter_folder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func TestPhotosFilterFolder(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})
t.Run("London pipe 2790/07", func(t *testing.T) {
t.Run("London whitespace pipe whitespace 2790/07", func(t *testing.T) {
var f form.SearchPhotos
f.Folder = "London | 2790/07"
Expand All @@ -72,8 +72,21 @@ func TestPhotosFilterFolder(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})*/
t.Run("London pipe 2790/07", func(t *testing.T) {
var f form.SearchPhotos

f.Folder = "London|2790/07"
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 2)
})
t.Run("StartsWithPercent", func(t *testing.T) {
var f form.SearchPhotos

Expand Down Expand Up @@ -513,9 +526,9 @@ func TestPhotosQueryFolder(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})
t.Run("London pipe 2790/07", func(t *testing.T) {
t.Run("London whitespace pipe whitespace 2790/07", func(t *testing.T) {
var f form.SearchPhotos
f.Query = "folder:\"London | 2790/07\""
Expand All @@ -526,8 +539,21 @@ func TestPhotosQueryFolder(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})*/
t.Run("London pipe 2790/07", func(t *testing.T) {
var f form.SearchPhotos

f.Query = "folder:\"London|2790/07\""
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 2)
})
t.Run("StartsWithPercent", func(t *testing.T) {
var f form.SearchPhotos

Expand Down
38 changes: 32 additions & 6 deletions internal/search/photos_filter_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func TestPhotosFilterPath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})
t.Run("London pipe 2790/07", func(t *testing.T) {
t.Run("London whitespace pipe whitespace 2790/07", func(t *testing.T) {
var f form.SearchPhotos
f.Path = "London | 2790/07"
Expand All @@ -72,8 +72,21 @@ func TestPhotosFilterPath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})*/
t.Run("London pipe 2790/07", func(t *testing.T) {
var f form.SearchPhotos

f.Path = "London|2790/07"
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 2)
})
t.Run("StartsWithPercent", func(t *testing.T) {
var f form.SearchPhotos

Expand Down Expand Up @@ -513,9 +526,9 @@ func TestPhotosQueryPath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})
t.Run("London pipe 2790/07", func(t *testing.T) {
t.Run("London whitespace pipe whitespace 2790/07", func(t *testing.T) {
var f form.SearchPhotos
f.Query = "path:\"London | 2790/07\""
Expand All @@ -526,8 +539,21 @@ func TestPhotosQueryPath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
assert.Equal(t, len(photos), 2)
})*/
t.Run("London pipe 2790/07", func(t *testing.T) {
var f form.SearchPhotos

f.Query = "path:\"London|2790/07\""
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 2)
})
t.Run("StartsWithPercent", func(t *testing.T) {
var f form.SearchPhotos

Expand Down
158 changes: 158 additions & 0 deletions internal/search/photos_filter_title_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,85 @@ import (
)

func TestPhotosFilterTitle(t *testing.T) {
t.Run("Lake / 2790", func(t *testing.T) {
var f form.SearchPhotos

f.Title = "Lake / 2790"
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
})
t.Run("Lake*", func(t *testing.T) {
var f form.SearchPhotos

f.Title = "Lake*"
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 2)
})
t.Run("Neckarbrücke", func(t *testing.T) {
var f form.SearchPhotos

f.Title = "Neckarbrücke"
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
})
//TODO Fix or search
/*t.Run("Neckarbrücke or Lake*", func(t *testing.T) {
var f form.SearchPhotos
f.Title = "Neckarbrücke OR Lake*"
f.Merged = true
photos, _, err := Photos(f)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 3)
})
t.Run("Neckarbrücke whitespace pipe whitespace Lake*", func(t *testing.T) {
var f form.SearchPhotos
f.Title = "Neckarbrücke | Lake*"
f.Merged = true
photos, _, err := Photos(f)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 3)
})*/
t.Run("Neckarbrücke pipe Lake*", func(t *testing.T) {
var f form.SearchPhotos

f.Title = "Neckarbrücke|Lake*"
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 3)
})
t.Run("StartsWithPercent", func(t *testing.T) {
var f form.SearchPhotos

Expand Down Expand Up @@ -341,6 +420,85 @@ func TestPhotosFilterTitle(t *testing.T) {
}

func TestPhotosQueryTitle(t *testing.T) {
t.Run("Lake / 2790", func(t *testing.T) {
var f form.SearchPhotos

f.Query = "title:\"Lake / 2790\""
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
})
t.Run("Lake*", func(t *testing.T) {
var f form.SearchPhotos

f.Query = "title:\"Lake*\""
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 2)
})
t.Run("Neckarbrücke", func(t *testing.T) {
var f form.SearchPhotos

f.Query = "title:\"Neckarbrücke\""
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 1)
})
//TODO Fix or search
/*t.Run("Neckarbrücke or Lake*", func(t *testing.T) {
var f form.SearchPhotos
f.Query = "title:\"Neckarbrücke OR Lake*\""
f.Merged = true
photos, _, err := Photos(f)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 3)
})
t.Run("Neckarbrücke whitespace pipe whitespace Lake*", func(t *testing.T) {
var f form.SearchPhotos
f.Query = "title:\"Neckarbrücke | Lake*\""
f.Merged = true
photos, _, err := Photos(f)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 3)
})*/
t.Run("Neckarbrücke pipe Lake*", func(t *testing.T) {
var f form.SearchPhotos

f.Query = "title:\"Neckarbrücke|Lake*\""
f.Merged = true

photos, _, err := Photos(f)

if err != nil {
t.Fatal(err)
}
assert.Equal(t, len(photos), 3)
})
t.Run("StartsWithPercent", func(t *testing.T) {
var f form.SearchPhotos

Expand Down

0 comments on commit d7f4c46

Please sign in to comment.