Backend: Add unit tests for internal/entity

This commit is contained in:
Theresa Gresch
2020-07-10 15:06:37 +02:00
parent 4196420dc7
commit d6c910c16b
5 changed files with 129 additions and 12 deletions

View File

@@ -42,6 +42,12 @@ func TestPhoto_EstimateCountry(t *testing.T) {
assert.Equal(t, "ca", m.CountryCode())
assert.Equal(t, "Canada", m.CountryName())
})
t.Run("photo has latlng", func(t *testing.T) {
m := Photo{PhotoTitle: "Port Lands / Gardiner Expressway / Toronto", PhotoLat: 13.333, PhotoLng: 40.998, PhotoName: "20120910_231851_CA06E1AD", OriginalName: "demo/Toronto/port-lands--gardiner-expressway--toronto_7999515645_o.jpg"}
m.EstimateCountry()
assert.Equal(t, "zz", m.CountryCode())
assert.Equal(t, "Unknown", m.CountryName())
})
}
func TestPhoto_Optimize(t *testing.T) {
@@ -59,4 +65,11 @@ func TestPhoto_Optimize(t *testing.T) {
t.Error("photo should NOT be updated")
}
})
t.Run("photo withouth id", func(t *testing.T) {
photo := Photo{}
bool, err := photo.Optimize()
assert.Error(t, err)
assert.False(t, bool)
})
}