-
Notifications
You must be signed in to change notification settings - Fork 12
/
client_test.go
28 lines (22 loc) · 975 Bytes
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package omgo
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestURLBuilder(t *testing.T) {
c, err := NewClient()
require.NoError(t, err)
loc, err := NewLocation(52.3738, 4.8910) // Amsterdam
require.NoError(t, err)
opts := Options{
TemperatureUnit: "celsius",
WindspeedUnit: "kmh",
PrecipitationUnit: "mm",
Timezone: "UTC",
PastDays: 1,
HourlyMetrics: []string{"temperature_2m", "cloudcover", "direct_radiation", "diffuse_radiation", "precipitation", "windspeed_10m"},
DailyMetrics: []string{"temperature_2m_max"},
}
url := urlFromOptions(c.URL, loc, &opts)
require.Equal(t, "https://api.open-meteo.com/v1/forecast?latitude=52.373800&longitude=4.891000¤t_weather=true&temperature_unit=celsius&windspeed_unit=kmh&precipitation_unit=mm&timezone=UTC&past_days=1&hourly=temperature_2m,cloudcover,direct_radiation,diffuse_radiation,precipitation,windspeed_10m&daily=temperature_2m_max", url)
}