From 4ef093d212abb22fbc87a6f9b8a06f5224677658 Mon Sep 17 00:00:00 2001 From: siddharth Date: Sun, 8 May 2022 22:27:46 -0400 Subject: add nws package --- nws/nws_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 nws/nws_test.go (limited to 'nws/nws_test.go') diff --git a/nws/nws_test.go b/nws/nws_test.go new file mode 100644 index 0000000..8c52c25 --- /dev/null +++ b/nws/nws_test.go @@ -0,0 +1,26 @@ +// Copyright © 2022 siddharth +// SPDX-License-Identifier: ISC + +package nws + +import "testing" + +func TestPoints(t *testing.T) { + // Test valid lat,lng. + np, err := points(41.115, -83.177) + if err != nil { + t.Errorf("points: %v", err) + } + if np.Properties.ForecastLink != "https://api.weather.gov/gridpoints/CLE/33,42/forecast" { + t.Errorf("points: forcecast link: '%v'", np.Properties.ForecastLink) + } + if np.Properties.ForecastHourlyLink != "https://api.weather.gov/gridpoints/CLE/33,42/forecast/hourly" { + t.Errorf("points: forcecast link: '%v'", np.Properties.ForecastHourlyLink) + } + + // Test invalid lat,lng + np, err = points(115.0, -83.177) + if err == nil { + t.Errorf("points: %v", np) + } +} -- cgit v1.2.3