diff options
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) + } + } +} |