2024-09-24 20:01:20 +00:00
|
|
|
package met
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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 TestForecast(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
c, err := New("my siteName")
|
|
|
|
assert.NoError(err)
|
|
|
|
|
|
|
|
f, err := c.Forecast(60.389444, 5.33, nil)
|
|
|
|
assert.NoError(err)
|
|
|
|
coords := f.Geometry.Coordinates
|
2024-09-24 20:18:08 +00:00
|
|
|
assert.Equal([]float64{5.33, 60.3894, 2}, coords)
|
2024-09-24 20:01:20 +00:00
|
|
|
|
|
|
|
_, err = c.Forecast(10000.0, 10000.33, nil)
|
|
|
|
assert.Error(err)
|
|
|
|
}
|