package nominatim import ( "strconv" "testing" "github.com/stretchr/testify/assert" ) func TestNewClient(t *testing.T) { assert := assert.New(t) c, err := New("my siteName") assert.NoError(err) assert.Equal("my siteName", c.siteName) _, err = New("") assert.Error(err) } func TestSearch(t *testing.T) { assert := assert.New(t) c, err := New("my siteName") assert.NoError(err) r, err := c.Search("bergen") assert.NoError(err) assert.NotEmpty(r) firstResult := (*r)[0] lon, err := strconv.ParseFloat(*firstResult.Longitude, 64) assert.NoError(err) lat, err := strconv.ParseFloat(*firstResult.Latitude, 64) assert.NoError(err) assert.Equal(5.3259192, lon) assert.Equal(60.3943055, lat) assert.Nil(firstResult.Address) } func TestLookup(t *testing.T) { assert := assert.New(t) c, err := New("my siteName") assert.NoError(err) r, err := c.Lookup("bergen") assert.NoError(err) assert.NotEmpty(r) assert.Equal(5.3259192, r.Longitude) assert.Equal(60.3943055, r.Latitude) _, err = c.Lookup("") assert.Error(err) }