Tests: Refactor unit tests
This commit is contained in:
parent
fe639e1ec6
commit
1431d54af0
4 changed files with 32 additions and 94 deletions
|
@ -60,7 +60,6 @@ func TestPhotosFilterFilename(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, 6, len(photos))
|
||||
})
|
||||
/* TODO: Support for " or " as an alias for | has been removed as filenames can contain "or"!
|
||||
t.Run("1990* or 2790/07/27900704_070228_D6D51B6C.jpg", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
Db().LogMode(true)
|
||||
|
@ -72,9 +71,8 @@ func TestPhotosFilterFilename(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, 6, len(photos))
|
||||
assert.Equal(t, 0, len(photos))
|
||||
})
|
||||
*/
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ func TestPhotosFilterType(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})
|
||||
//TODO
|
||||
/*t.Run("raw whitespace pipe whitespace video", func(t *testing.T) {
|
||||
t.Run("raw whitespace pipe whitespace video", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Type = "raw | video"
|
||||
|
@ -73,7 +72,7 @@ func TestPhotosFilterType(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
assert.Equal(t, len(photos), 0)
|
||||
})
|
||||
t.Run("raw OR video", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
@ -86,8 +85,8 @@ func TestPhotosFilterType(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})*/
|
||||
assert.Equal(t, len(photos), 0)
|
||||
})
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -367,8 +366,7 @@ func TestPhotosQueryType(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})
|
||||
//TODO
|
||||
/*t.Run("raw whitespace pipe whitespace video", func(t *testing.T) {
|
||||
t.Run("raw whitespace pipe whitespace video", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Query = "type:\"raw | video\""
|
||||
|
@ -392,7 +390,7 @@ func TestPhotosQueryType(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
assert.Equal(t, len(photos), 0)
|
||||
})
|
||||
t.Run("raw OR video", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
@ -405,8 +403,8 @@ func TestPhotosQueryType(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})*/
|
||||
assert.Equal(t, len(photos), 0)
|
||||
})
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
|
|
@ -22,8 +22,7 @@ func TestPhotosFilterUid(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 1)
|
||||
})
|
||||
//TODO wildcard
|
||||
/*t.Run("pt9jtdre2lvl0yh*", func(t *testing.T) {
|
||||
t.Run("pt9jtdre2lvl0yh*", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.UID = "pt9jtdre2lvl0yh*"
|
||||
|
@ -34,8 +33,8 @@ func TestPhotosFilterUid(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Greater(t, len(photos), 1)
|
||||
})*/
|
||||
assert.Equal(t, len(photos), 0)
|
||||
})
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -289,8 +288,7 @@ func TestPhotosQueryUid(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 1)
|
||||
})
|
||||
//TODO wildcard
|
||||
/*t.Run("pt9jtdre2lvl0yh*", func(t *testing.T) {
|
||||
t.Run("pt9jtdre2lvl0yh*", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Query = "uid:\"pt9jtdre2lvl0yh*\""
|
||||
|
@ -301,8 +299,8 @@ func TestPhotosQueryUid(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Greater(t, len(photos), 1)
|
||||
})*/
|
||||
assert.Equal(t, len(photos), 0)
|
||||
})
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ import (
|
|||
)
|
||||
|
||||
func TestPhotosFilterYear(t *testing.T) {
|
||||
var f0 form.SearchPhotos
|
||||
|
||||
f0.Merged = true
|
||||
|
||||
photos0, _, _ := Photos(f0)
|
||||
t.Run("2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -35,8 +40,7 @@ func TestPhotosFilterYear(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 2)
|
||||
})
|
||||
//TODO Wildcard fails
|
||||
/*t.Run("19*", func(t *testing.T) {
|
||||
t.Run("19*", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Year = "19*"
|
||||
|
@ -47,8 +51,8 @@ func TestPhotosFilterYear(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 2)
|
||||
})*/
|
||||
assert.Equal(t, len(photos), len(photos0))
|
||||
})
|
||||
t.Run("2018 pipe 2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -75,38 +79,6 @@ func TestPhotosFilterYear(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})
|
||||
//TODO
|
||||
/*t.Run("2018 or 2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Year = "2018 or 2008"
|
||||
f.Merged = true
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})
|
||||
t.Run("2018 OR 2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Year = "2018 OR 2008"
|
||||
f.Merged = true
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})*/
|
||||
var f0 form.SearchPhotos
|
||||
|
||||
f0.Merged = true
|
||||
|
||||
photos0, _, _ := Photos(f0)
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -347,6 +319,12 @@ func TestPhotosFilterYear(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPhotosQueryYear(t *testing.T) {
|
||||
var f0 form.SearchPhotos
|
||||
|
||||
f0.Merged = true
|
||||
|
||||
photos0, _, _ := Photos(f0)
|
||||
|
||||
t.Run("2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -373,8 +351,7 @@ func TestPhotosQueryYear(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 2)
|
||||
})
|
||||
//TODO Wildcard fails
|
||||
/*t.Run("19*", func(t *testing.T) {
|
||||
t.Run("19*", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Query = "year:\"19*\""
|
||||
|
@ -385,8 +362,8 @@ func TestPhotosQueryYear(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 2)
|
||||
})*/
|
||||
assert.Equal(t, len(photos), len(photos0))
|
||||
})
|
||||
t.Run("2018 pipe 2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
@ -413,39 +390,6 @@ func TestPhotosQueryYear(t *testing.T) {
|
|||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})
|
||||
//TODO
|
||||
/*t.Run("2018 or 2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Query = "year:\"2018 or 2008\""
|
||||
f.Merged = true
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})
|
||||
t.Run("2018 OR 2008", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
f.Query = "year:\"2018 OR 2008\""
|
||||
f.Merged = true
|
||||
|
||||
photos, _, err := Photos(f)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assert.Equal(t, len(photos), 4)
|
||||
})*/
|
||||
var f0 form.SearchPhotos
|
||||
|
||||
f0.Merged = true
|
||||
|
||||
photos0, _, _ := Photos(f0)
|
||||
|
||||
t.Run("StartsWithPercent", func(t *testing.T) {
|
||||
var f form.SearchPhotos
|
||||
|
||||
|
|
Loading…
Reference in a new issue