diff options
author | siddharth <s@ricketyspace.net> | 2022-05-16 21:48:43 -0400 |
---|---|---|
committer | siddharth <s@ricketyspace.net> | 2022-05-16 21:48:43 -0400 |
commit | 63a35560a1566b9f8ca8ddd2b436003b520c6876 (patch) | |
tree | 07dda36ba86763717223b28075b6494baafd436e /nws/nws_test.go | |
parent | cbc777005e2d344151ea5c1984a33ff7b262b79a (diff) |
nws: add ForecastHourly
Diffstat (limited to 'nws/nws_test.go')
-rw-r--r-- | nws/nws_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
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) + } + } +} |