Tests: Adapt tests to fixture changes

This commit is contained in:
theresa 2021-08-05 12:33:52 +02:00
parent c13af0408d
commit 9263895408
10 changed files with 27 additions and 17 deletions

View file

@ -17,7 +17,7 @@ func TestGetFile(t *testing.T) {
assert.Equal(t, http.StatusOK, r.Code)
val := gjson.Get(r.Body.String(), "Name")
assert.Equal(t, "2020/07/exampleFileName.jpg", val.String())
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", val.String())
})
t.Run("search for not existing file", func(t *testing.T) {
app, router, _ := NewApiTest()

View file

@ -15,8 +15,8 @@ func TestGetPhoto(t *testing.T) {
GetPhoto(router)
r := PerformRequest(app, "GET", "/api/v1/photos/pt9jtdre2lvl0yh7")
assert.Equal(t, http.StatusOK, r.Code)
val := gjson.Get(r.Body.String(), "Lat")
assert.Equal(t, "48.519234", val.String())
val := gjson.Get(r.Body.String(), "Iso")
assert.Equal(t, "200", val.String())
})
t.Run("search for not existing photo", func(t *testing.T) {

View file

@ -12,7 +12,7 @@ var FileFixtures = map[string]File{
PhotoUID: PhotoFixtures.Pointer("19800101_000002_D640C559").PhotoUID,
InstanceID: "a698ac56-6e7e-42b9-9c3e-a79ec96087uy",
FileUID: "ft8es39w45bnlqdw",
FileName: "2020/07/exampleFileName.jpg",
FileName: "2790/07/27900704_070228_D6D51B6C.jpg",
FileRoot: RootOriginals,
OriginalName: "Vacation/exampleFileNameOriginal.jpg",
FileHash: "2cad9168fa6acc5c5c2965ddf6ec465ca42fd818",
@ -43,9 +43,9 @@ var FileFixtures = map[string]File{
FileShareFixtures.Get("FileShare2", 0, 0, ""),
},
Sync: []FileSync{},
CreatedAt: time.Date(2020, 3, 6, 2, 6, 51, 0, time.UTC),
CreatedAt: time.Date(2009, 1, 1, 0, 0, 0, 0, time.UTC),
CreatedIn: 414671279,
UpdatedAt: time.Date(2020, 3, 28, 14, 6, 0, 0, time.UTC),
UpdatedAt: time.Date(2008, 1, 1, 0, 0, 0, 0, time.UTC),
UpdatedIn: 847648638,
DeletedAt: nil,
},

View file

@ -10,7 +10,7 @@ func TestPhotoMap_Get(t *testing.T) {
t.Run("get existing photo", func(t *testing.T) {
r := PhotoFixtures.Get("19800101_000002_D640C559")
assert.Equal(t, "pt9jtdre2lvl0yh7", r.PhotoUID)
assert.Equal(t, "19800101_000002_D640C559", r.PhotoName)
assert.Equal(t, "27900704_070228_D6D51B6C", r.PhotoName)
assert.IsType(t, Photo{}, r)
})
t.Run("get not existing photo", func(t *testing.T) {
@ -24,7 +24,7 @@ func TestPhotoMap_Pointer(t *testing.T) {
t.Run("get existing photo pointer", func(t *testing.T) {
r := PhotoFixtures.Pointer("19800101_000002_D640C559")
assert.Equal(t, "pt9jtdre2lvl0yh7", r.PhotoUID)
assert.Equal(t, "19800101_000002_D640C559", r.PhotoName)
assert.Equal(t, "27900704_070228_D6D51B6C", r.PhotoName)
assert.IsType(t, &Photo{}, r)
})
t.Run("get not existing photo pointer", func(t *testing.T) {

View file

@ -8,7 +8,7 @@ import (
func TestPhoto_QualityScore(t *testing.T) {
t.Run("PhotoFixture19800101_000002_D640C559", func(t *testing.T) {
assert.Equal(t, 4, PhotoFixtures.Pointer("19800101_000002_D640C559").QualityScore())
assert.Equal(t, 3, PhotoFixtures.Pointer("19800101_000002_D640C559").QualityScore())
})
t.Run("PhotoFixturePhoto01 - favorite true - taken at before 2008", func(t *testing.T) {
assert.Equal(t, 7, PhotoFixtures.Pointer("Photo01").QualityScore())

View file

@ -452,15 +452,25 @@ func TestPhoto_UpdateTitle(t *testing.T) {
}
assert.Equal(t, "shortcity / Germany / 2016", m.PhotoTitle)
})
t.Run("no location", func(t *testing.T) {
t.Run("no location original name", func(t *testing.T) {
m := PhotoFixtures.Get("19800101_000002_D640C559")
classifyLabels := &classify.Labels{{Name: "classify", Uncertainty: 30, Source: SrcManual, Priority: 5, Categories: []string{"flower", "plant"}}}
assert.Equal(t, "Lake / 2790", m.PhotoTitle)
err := m.UpdateTitle(*classifyLabels)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Examplefilenameoriginal", m.PhotoTitle)
})
t.Run("no location", func(t *testing.T) {
m := PhotoFixtures.Get("Photo01")
classifyLabels := &classify.Labels{{Name: "classify", Uncertainty: 30, Source: SrcManual, Priority: 5, Categories: []string{"flower", "plant"}}}
assert.Equal(t, "", m.PhotoTitle)
err := m.UpdateTitle(*classifyLabels)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Classify / 2008", m.PhotoTitle)
assert.Equal(t, "Classify / 2006", m.PhotoTitle)
})
t.Run("no location no labels", func(t *testing.T) {
m := PhotoFixtures.Get("Photo02")

View file

@ -15,7 +15,7 @@ func TestFiles_Ignore(t *testing.T) {
t.Fatal(err)
}
assert.True(t, files.Ignore("2020/07/exampleFileName.jpg", entity.RootOriginals, time.Unix(1583460411, 0), false))
assert.True(t, files.Ignore("2790/07/27900704_070228_D6D51B6C.jpg", entity.RootOriginals, time.Unix(1583460411, 0), false))
assert.False(t, files.Ignore("exampleFileName.jpg", entity.RootOriginals, time.Unix(1583460412, 0), false))
assert.True(t, files.Ignore("exampleFileName.jpg", entity.RootOriginals, time.Unix(1583460412, 0), false))
assert.False(t, files.Ignore("exampleFileName.jpg", entity.RootOriginals, time.Unix(1583460412, 0), true))

View file

@ -34,7 +34,7 @@ func TestAlbumCoverByUID(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, "2020/07/exampleFileName.jpg", file.FileName)
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", file.FileName)
})
t.Run("existing uid folder album", func(t *testing.T) {

View file

@ -75,7 +75,7 @@ func TestFilesByUID(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, 1, len(files))
assert.Equal(t, "2020/07/exampleFileName.jpg", files[0].FileName)
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", files[0].FileName)
})
t.Run("no files found", func(t *testing.T) {
files, err := FilesByUID([]string{"ft8es39w45bnlxxx"}, 100, 0)
@ -137,7 +137,7 @@ func TestFileByUID(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, "2020/07/exampleFileName.jpg", file.FileName)
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", file.FileName)
})
t.Run("no files found", func(t *testing.T) {
@ -159,7 +159,7 @@ func TestFileByHash(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "2020/07/exampleFileName.jpg", file.FileName)
assert.Equal(t, "2790/07/27900704_070228_D6D51B6C.jpg", file.FileName)
})
t.Run("no files found", func(t *testing.T) {

View file

@ -511,7 +511,7 @@ func TestPhotoSearch(t *testing.T) {
f.Count = 5000
f.Offset = 0
f.Lens = 1000000
f.Month = 2
f.Month = 7
f.Year = 2790
f.Album = "at9lxuqxpogaaba8"