yr/internal/met/met_test.go
Tim Hårek Andreassen 012bd95cbb
refactor: Use query params instead of sprintf
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
2024-09-24 22:18:08 +02:00

32 lines
597 B
Go

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
assert.Equal([]float64{5.33, 60.3894, 2}, coords)
_, err = c.Forecast(10000.0, 10000.33, nil)
assert.Error(err)
}