photoprism/internal/entity/place_fixtures_test.go

37 lines
1,020 B
Go
Raw Normal View History

2020-05-12 13:52:09 +02:00
package entity
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestPlaceMap_Get(t *testing.T) {
t.Run("get existing place", func(t *testing.T) {
r := PlaceFixtures.Get("mexico")
2020-05-12 13:52:09 +02:00
assert.Equal(t, "Teotihuacán", r.LocCity)
assert.Equal(t, "State of Mexico", r.LocState)
2020-05-12 13:52:09 +02:00
assert.IsType(t, Place{}, r)
})
t.Run("get not existing place", func(t *testing.T) {
r := PlaceFixtures.Get("xxx")
assert.Equal(t, "Unknown", r.LocCity)
assert.Equal(t, "Unknown", r.LocState)
assert.IsType(t, Place{}, r)
})
}
func TestPlaceMap_Pointer(t *testing.T) {
t.Run("get existing place pointer", func(t *testing.T) {
r := PlaceFixtures.Pointer("mexico")
2020-05-12 13:52:09 +02:00
assert.Equal(t, "Teotihuacán", r.LocCity)
assert.Equal(t, "State of Mexico", r.LocState)
2020-05-12 13:52:09 +02:00
assert.IsType(t, &Place{}, r)
})
t.Run("get not existing place pointer", func(t *testing.T) {
r := PlaceFixtures.Pointer("xxx")
assert.Equal(t, "Unknown", r.LocCity)
assert.Equal(t, "Unknown", r.LocState)
assert.IsType(t, &Place{}, r)
})
}