-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathweather_test.go
37 lines (32 loc) · 1.01 KB
/
weather_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
29
30
31
32
33
34
35
36
37
package weatherkit
import (
"testing"
"time"
)
func TestWeatherRequestFullUrlGeneration(t *testing.T) {
ts, _ := time.Parse(dateTimeFormat, "2022-07-10T06:14:11Z")
req := WeatherRequest{
Language: "en",
Latitude: 40.713,
Longitude: -74.006,
CountryCode: "US",
CurrentAsOf: &ts,
DailyEnd: &ts,
DailyStart: &ts,
HourlyEnd: &ts,
HourlyStart: &ts,
Timezone: "America/New_York",
DataSets: DataSets{
DataSetCurrentWeather,
DataSetForecastDaily,
DataSetForecastHourly,
DataSetForecastNextHour,
DataSetWeatherAlerts,
},
}
want := BaseUrl + "/api/v1/weather/en/40.713/-74.006?countryCode=US¤tAsOf=2022-07-10T06%3A14%3A11Z&dailyEnd=2022-07-10T06%3A14%3A11Z&dailyStart=2022-07-10T06%3A14%3A11Z&dataSets=currentWeather%2CforecastDaily%2CforecastHourly%2CforecastNextHour%2CweatherAlerts&hourlyEnd=2022-07-10T06%3A14%3A11Z&hourlyStart=2022-07-10T06%3A14%3A11Z&timezone=America%2FNew_York"
have := req.url()
if want != have {
t.Errorf("want: %s, have: %s", want, have)
}
}