From 6cac63ec95ce2d6b8a8fd3694f0784ef311690f5 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Wed, 13 Jul 2022 23:32:21 -0400 Subject: nws: add `GetForecastGridData` --- nws/nws_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'nws/nws_test.go') diff --git a/nws/nws_test.go b/nws/nws_test.go index 88f1c2b..7ddd97f 100644 --- a/nws/nws_test.go +++ b/nws/nws_test.go @@ -151,6 +151,41 @@ func TestGetForecastHourly(t *testing.T) { } } +func TestGetForecastGridData(t *testing.T) { + // Get point. + np, nwsErr := Points(41.115, -83.177) + if nwsErr != nil { + t.Errorf("error: %v", nwsErr) + return + } + + // Get forecast grid data + grid, nwsErr := GetForecastGridData(np) + if nwsErr != nil { + t.Errorf("error: %v", nwsErr) + return + } + + if len(grid.Properties.RelativeHumidity.Values) < 1 { + t.Error("error: humidity values empty") + return + } + + // Verify humidity values. + for i, value := range grid.Properties.RelativeHumidity.Values { + if len(value.ValidTime) < 1 { + t.Errorf("humidity: %d: valid time invalid: %v", i, + value.ValidTime) + return + } + if value.Value < 1 { + t.Errorf("humidity: %d: value invalid: %v", i, + value.Value) + return + } + } +} + func TestNWSGetWrapper(t *testing.T) { // Initialize test NWS server. fails := 0 -- cgit v1.2.3