From 63a35560a1566b9f8ca8ddd2b436003b520c6876 Mon Sep 17 00:00:00 2001 From: siddharth Date: Mon, 16 May 2022 21:48:43 -0400 Subject: nws: add ForecastHourly --- nws/nws_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'nws/nws_test.go') diff --git a/nws/nws_test.go b/nws/nws_test.go index ea47188..7dd5780 100644 --- a/nws/nws_test.go +++ b/nws/nws_test.go @@ -85,3 +85,50 @@ func TestForecast(t *testing.T) { } } } + +func TestForecastHourly(t *testing.T) { + // Get point. + np, err := Points(41.115, -83.177) + if err != nil { + t.Errorf("error: %v", err) + return + } + + // Get forecast hourly. + fc, err := ForecastHourly(np) + if err != nil { + t.Errorf("error: %v", err) + return + } + + // Verify periods. + for i, period := range fc.Properties.Periods { + if period.Number < 1 { + t.Errorf("period: %d: number invalid: %v", i, period.Number) + } + if len(period.StartTime) < 1 { + t.Errorf("period: %d: start time invalid: %v", i, + period.StartTime) + } + if len(period.EndTime) < 1 { + t.Errorf("period: %d: end time invalid: %v", i, + period.EndTime) + } + if len(period.TemperatureUnit) < 1 { + t.Errorf("period: %d: temperature unit invalid: %v", + i, period.TemperatureUnit) + } + if len(period.WindSpeed) < 1 { + t.Errorf("period: %d: wind speed invalid: %v", + i, period.WindSpeed) + } + if len(period.WindDirection) < 1 { + t.Errorf("period: %d: wind direction invalid: %v", + i, period.WindDirection) + } + if len(period.ShortForecast) < 1 { + t.Errorf("period: %d: short forecast invalid: %v", + i, period.ShortForecast) + } + } +} -- cgit v1.2.3