From 5449a64ccc29f56618412d746f785a395d6d15a7 Mon Sep 17 00:00:00 2001 From: "RobLabs.com" Date: Mon, 11 Apr 2022 15:13:15 -0700 Subject: [PATCH 1/3] Allow API customers to set the UnitTemperature to get either US or SI (metric) results from the API --- .../services/calls/NWS+Forecast.swift | 8 +++- .../GetForecastIntegrationTests.swift | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Sources/NationalWeatherService/services/calls/NWS+Forecast.swift b/Sources/NationalWeatherService/services/calls/NWS+Forecast.swift index 72a878b..bd517df 100644 --- a/Sources/NationalWeatherService/services/calls/NWS+Forecast.swift +++ b/Sources/NationalWeatherService/services/calls/NWS+Forecast.swift @@ -10,10 +10,16 @@ import Foundation extension NationalWeatherService { public typealias ForecastHandler = (Result) -> Void + /// Allow API customers to set the [UnitTemperature](https://developer.apple.com/documentation/foundation/unittemperature) + /// to get ["*US customary or SI (metric) units in textual output*"](https://www.weather.gov/documentation/services-web-api#/default/gridpoint_forecast) + public static var units: UnitTemperature = .celsius + fileprivate func loadForecast(at url: URL, then handler: @escaping ForecastHandler) { var components = URLComponents(url: url, resolvingAgainstBaseURL: false)! + + let units: String = NationalWeatherService.units == .celsius ? "si" : "us" components.queryItems = [ - URLQueryItem(name: "units", value: "si") + URLQueryItem(name: "units", value: units) ] self.load(at: components.url!, as: Forecast.self, then: handler) diff --git a/Tests/NationalWeatherServiceTests/integration/GetForecastIntegrationTests.swift b/Tests/NationalWeatherServiceTests/integration/GetForecastIntegrationTests.swift index b82cc6b..a85910d 100644 --- a/Tests/NationalWeatherServiceTests/integration/GetForecastIntegrationTests.swift +++ b/Tests/NationalWeatherServiceTests/integration/GetForecastIntegrationTests.swift @@ -2,6 +2,7 @@ import XCTest @testable import NationalWeatherService final class GetForecastIntegrationTests: XCTestCase { + /// Get forecast without setting `NationalWeatherService.units` func testGetForecastForLocation() throws { let forecastExpectation = self.expectation(description: "get forecast expectation") nws.forecast(latitude: 47.6174, longitude: -122.2017) { result in @@ -15,7 +16,44 @@ final class GetForecastIntegrationTests: XCTestCase { wait(for: [forecastExpectation], timeout: 5) } + + /// Get forecast by setting `NationalWeatherService.units` to `.fahrenheit` + func testGetForecastFahrenheit() throws { + let forecastExpectation = self.expectation(description: "get forecast expectation") + + NationalWeatherService.units = .fahrenheit + nws.forecast(latitude: 47.6174, longitude: -122.2017) { result in + XCTAssertSuccess(result) + + let forecast = try! result.get() + print(forecast) + XCTAssertFalse(forecast.periods.isEmpty) + forecastExpectation.fulfill() + } + + wait(for: [forecastExpectation], timeout: 5) + } + + /// Get forecast by setting `NationalWeatherService.units` to `.celsius` + func testGetForecastCelsius() throws { + let forecastExpectation = self.expectation(description: "get forecast expectation") + + NationalWeatherService.units = .celsius + nws.forecast(latitude: 47.6174, longitude: -122.2017) { result in + XCTAssertSuccess(result) + + let forecast = try! result.get() + + print(forecast) + XCTAssertFalse(forecast.periods.isEmpty) + + forecastExpectation.fulfill() + } + + wait(for: [forecastExpectation], timeout: 5) + } + func testGetHourlyForecast() throws { let hourlyForecastExpectation = self.expectation(description: "get hourly forecast expectation") nws.hourlyForecast(latitude: 47.6174, longitude: -122.2017) { result in From 59ec240b474a2da1ea7459743327130b0d4e3dd3 Mon Sep 17 00:00:00 2001 From: "RobLabs.com" Date: Thu, 22 Aug 2024 07:37:27 -0700 Subject: [PATCH 2/3] Update Swift Package dependencies: GeoSwift & geos. Fixes errors when compiling with Xcode 16 --- Package.resolved | 8 ++++---- Package.swift | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Package.resolved b/Package.resolved index a78d7d7..7eccbcf 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/GEOSwift/geos.git", "state": { "branch": null, - "revision": "083e366bc831d0f951974151315383830a79d447", - "version": "5.0.0" + "revision": "f510e634c822116fca615064d889300dba40d761", + "version": "8.1.0" } }, { @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/GEOSwift/GEOSwift.git", "state": { "branch": null, - "revision": "7e27a3b92b2ea61cf63ef1664bbe5c734cbb7447", - "version": "7.1.0" + "revision": "1fee0146ee06ca2d1e83070320b95526f3690f9d", + "version": "10.2.0" } } ] diff --git a/Package.swift b/Package.swift index fcd3bc0..7d39ae0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.2 +// swift-tools-version:5.5 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -18,8 +18,8 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(url: "https://github.com/GEOSwift/GEOSwift.git", from: "7.0.0"), - .package(url: "https://github.com/GEOSwift/geos.git", from: "5.0.0") + .package(url: "https://github.com/GEOSwift/GEOSwift.git", from: "10.0.0"), + .package(url: "https://github.com/GEOSwift/geos.git", from: "8.0.0") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. From aeac7e979b9fdd8158f53186831da1d0be3a03ab Mon Sep 17 00:00:00 2001 From: "RobLabs.com" Date: Thu, 22 Aug 2024 08:10:58 -0700 Subject: [PATCH 3/3] The `Forecast` model has been now uses `updatedTime`. See discussion: https://github.com/weather-gov/api/discussions/733 Depends on https://github.com/WeatherProvider/NationalWeatherService-Swift/pull/16 --- .../NationalWeatherService/models/Forecast/Forecast.swift | 6 +++--- .../fixtures/ForecastFixtures.swift | 2 +- .../NationalWeatherServiceTests/models/ForecastTests.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/NationalWeatherService/models/Forecast/Forecast.swift b/Sources/NationalWeatherService/models/Forecast/Forecast.swift index ad68a4e..bcf9388 100644 --- a/Sources/NationalWeatherService/models/Forecast/Forecast.swift +++ b/Sources/NationalWeatherService/models/Forecast/Forecast.swift @@ -9,10 +9,10 @@ import Foundation public struct Forecast: Decodable { public enum CodingKeys: String, CodingKey { - case updated, generatedAt, validTimes, elevation, periods + case updateTime, generatedAt, validTimes, elevation, periods } - public let updated: Date + public let updateTime: Date public let generatedAt: Date // TODO: Handle valid times interval @@ -23,7 +23,7 @@ public struct Forecast: Decodable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self.updated = try container.decode(Date.self, forKey: .updated) + self.updateTime = try container.decode(Date.self, forKey: .updateTime) self.generatedAt = try container.decode(Date.self, forKey: .generatedAt) let validTimesValue = try container.decode(String.self, forKey: .validTimes) diff --git a/Tests/NationalWeatherServiceTests/fixtures/ForecastFixtures.swift b/Tests/NationalWeatherServiceTests/fixtures/ForecastFixtures.swift index ee54176..daed193 100644 --- a/Tests/NationalWeatherServiceTests/fixtures/ForecastFixtures.swift +++ b/Tests/NationalWeatherServiceTests/fixtures/ForecastFixtures.swift @@ -1,6 +1,6 @@ import Foundation extension Fixtures { - static let Forecast_Only_Fixture_SEAW = #"{"updated":"2020-04-02T23:05:37+00:00","units":"us","forecastGenerator":"BaselineForecastGenerator","generatedAt":"2020-04-03T03:43:53+00:00","updateTime":"2020-04-02T23:05:37+00:00","validTimes":"2020-04-02T17:00:00+00:00\/P7DT20H","elevation":{"value":56.997600000000006,"unitCode":"unit:m"},"periods":[{"number":1,"name":"Tonight","startTime":"2020-04-02T20:00:00-07:00","endTime":"2020-04-03T06:00:00-07:00","isDaytime":false,"temperature":37,"temperatureUnit":"F","temperatureTrend":"rising","windSpeed":"1 to 6 mph","windDirection":"SE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain_showers,30\/rain_showers,50?size=medium","shortForecast":"Chance Rain Showers","detailedForecast":"A chance of rain showers. Mostly cloudy. Low around 37, with temperatures rising to around 39 overnight. Southeast wind 1 to 6 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible."},{"number":2,"name":"Friday","startTime":"2020-04-03T06:00:00-07:00","endTime":"2020-04-03T18:00:00-07:00","isDaytime":true,"temperature":46,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"5 to 10 mph","windDirection":"WSW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain_showers,50?size=medium","shortForecast":"Chance Rain Showers","detailedForecast":"A chance of rain showers. Partly sunny, with a high near 46. West southwest wind 5 to 10 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible."},{"number":3,"name":"Friday Night","startTime":"2020-04-03T18:00:00-07:00","endTime":"2020-04-04T06:00:00-07:00","isDaytime":false,"temperature":35,"temperatureUnit":"F","temperatureTrend":"rising","windSpeed":"2 to 6 mph","windDirection":"NE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain,40\/rain,20?size=medium","shortForecast":"Slight Chance Light Rain","detailedForecast":"A chance of rain showers before 11pm, then a slight chance of rain between 11pm and 5am. Mostly cloudy. Low around 35, with temperatures rising to around 37 overnight. Northeast wind 2 to 6 mph. Chance of precipitation is 40%. New rainfall amounts less than a tenth of an inch possible."},{"number":4,"name":"Saturday","startTime":"2020-04-04T06:00:00-07:00","endTime":"2020-04-04T18:00:00-07:00","isDaytime":true,"temperature":52,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 to 8 mph","windDirection":"N","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/bkn?size=medium","shortForecast":"Partly Sunny","detailedForecast":"Partly sunny, with a high near 52. North wind 2 to 8 mph."},{"number":5,"name":"Saturday Night","startTime":"2020-04-04T18:00:00-07:00","endTime":"2020-04-05T06:00:00-07:00","isDaytime":false,"temperature":39,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"0 to 8 mph","windDirection":"NNE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain,20?size=medium","shortForecast":"Slight Chance Light Rain","detailedForecast":"A slight chance of rain after 11pm. Mostly cloudy, with a low around 39. North northeast wind 0 to 8 mph. Chance of precipitation is 20%. New rainfall amounts less than a tenth of an inch possible."},{"number":6,"name":"Sunday","startTime":"2020-04-05T06:00:00-07:00","endTime":"2020-04-05T18:00:00-07:00","isDaytime":true,"temperature":54,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"0 to 3 mph","windDirection":"N","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain,30?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain. Partly sunny, with a high near 54. Chance of precipitation is 30%. New rainfall amounts less than a tenth of an inch possible."},{"number":7,"name":"Sunday Night","startTime":"2020-04-05T18:00:00-07:00","endTime":"2020-04-06T06:00:00-07:00","isDaytime":false,"temperature":39,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"0 to 3 mph","windDirection":"N","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain,20?size=medium","shortForecast":"Slight Chance Light Rain","detailedForecast":"A slight chance of rain. Mostly cloudy, with a low around 39. Chance of precipitation is 20%."},{"number":8,"name":"Monday","startTime":"2020-04-06T06:00:00-07:00","endTime":"2020-04-06T18:00:00-07:00","isDaytime":true,"temperature":56,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NNW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain\/bkn?size=medium","shortForecast":"Slight Chance Light Rain then Partly Sunny","detailedForecast":"A slight chance of rain before 11am. Partly sunny, with a high near 56."},{"number":9,"name":"Monday Night","startTime":"2020-04-06T18:00:00-07:00","endTime":"2020-04-07T06:00:00-07:00","isDaytime":false,"temperature":38,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/sct?size=medium","shortForecast":"Partly Cloudy","detailedForecast":"Partly cloudy, with a low around 38."},{"number":10,"name":"Tuesday","startTime":"2020-04-07T06:00:00-07:00","endTime":"2020-04-07T18:00:00-07:00","isDaytime":true,"temperature":59,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"SW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/sct?size=medium","shortForecast":"Mostly Sunny","detailedForecast":"Mostly sunny, with a high near 59."},{"number":11,"name":"Tuesday Night","startTime":"2020-04-07T18:00:00-07:00","endTime":"2020-04-08T06:00:00-07:00","isDaytime":false,"temperature":40,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NNE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/sct\/rain?size=medium","shortForecast":"Partly Cloudy then Slight Chance Light Rain","detailedForecast":"A slight chance of rain after 5am. Partly cloudy, with a low around 40."},{"number":12,"name":"Wednesday","startTime":"2020-04-08T06:00:00-07:00","endTime":"2020-04-08T18:00:00-07:00","isDaytime":true,"temperature":60,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"3 mph","windDirection":"WSW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain. Partly sunny, with a high near 60."},{"number":13,"name":"Wednesday Night","startTime":"2020-04-08T18:00:00-07:00","endTime":"2020-04-09T06:00:00-07:00","isDaytime":false,"temperature":41,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NNW","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain. Mostly cloudy, with a low around 41."},{"number":14,"name":"Thursday","startTime":"2020-04-09T06:00:00-07:00","endTime":"2020-04-09T18:00:00-07:00","isDaytime":true,"temperature":59,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"3 mph","windDirection":"WSW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain before 5pm, then a chance of rain showers. Partly sunny, with a high near 59."}]}"#.data(using: .utf8)! + static let Forecast_Only_Fixture_SEAW = #"{"updateTime":"2020-04-02T23:05:37+00:00","units":"us","forecastGenerator":"BaselineForecastGenerator","generatedAt":"2020-04-03T03:43:53+00:00","updateTime":"2020-04-02T23:05:37+00:00","validTimes":"2020-04-02T17:00:00+00:00\/P7DT20H","elevation":{"value":56.997600000000006,"unitCode":"unit:m"},"periods":[{"number":1,"name":"Tonight","startTime":"2020-04-02T20:00:00-07:00","endTime":"2020-04-03T06:00:00-07:00","isDaytime":false,"temperature":37,"temperatureUnit":"F","temperatureTrend":"rising","windSpeed":"1 to 6 mph","windDirection":"SE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain_showers,30\/rain_showers,50?size=medium","shortForecast":"Chance Rain Showers","detailedForecast":"A chance of rain showers. Mostly cloudy. Low around 37, with temperatures rising to around 39 overnight. Southeast wind 1 to 6 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible."},{"number":2,"name":"Friday","startTime":"2020-04-03T06:00:00-07:00","endTime":"2020-04-03T18:00:00-07:00","isDaytime":true,"temperature":46,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"5 to 10 mph","windDirection":"WSW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain_showers,50?size=medium","shortForecast":"Chance Rain Showers","detailedForecast":"A chance of rain showers. Partly sunny, with a high near 46. West southwest wind 5 to 10 mph. Chance of precipitation is 50%. New rainfall amounts less than a tenth of an inch possible."},{"number":3,"name":"Friday Night","startTime":"2020-04-03T18:00:00-07:00","endTime":"2020-04-04T06:00:00-07:00","isDaytime":false,"temperature":35,"temperatureUnit":"F","temperatureTrend":"rising","windSpeed":"2 to 6 mph","windDirection":"NE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain,40\/rain,20?size=medium","shortForecast":"Slight Chance Light Rain","detailedForecast":"A chance of rain showers before 11pm, then a slight chance of rain between 11pm and 5am. Mostly cloudy. Low around 35, with temperatures rising to around 37 overnight. Northeast wind 2 to 6 mph. Chance of precipitation is 40%. New rainfall amounts less than a tenth of an inch possible."},{"number":4,"name":"Saturday","startTime":"2020-04-04T06:00:00-07:00","endTime":"2020-04-04T18:00:00-07:00","isDaytime":true,"temperature":52,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 to 8 mph","windDirection":"N","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/bkn?size=medium","shortForecast":"Partly Sunny","detailedForecast":"Partly sunny, with a high near 52. North wind 2 to 8 mph."},{"number":5,"name":"Saturday Night","startTime":"2020-04-04T18:00:00-07:00","endTime":"2020-04-05T06:00:00-07:00","isDaytime":false,"temperature":39,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"0 to 8 mph","windDirection":"NNE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain,20?size=medium","shortForecast":"Slight Chance Light Rain","detailedForecast":"A slight chance of rain after 11pm. Mostly cloudy, with a low around 39. North northeast wind 0 to 8 mph. Chance of precipitation is 20%. New rainfall amounts less than a tenth of an inch possible."},{"number":6,"name":"Sunday","startTime":"2020-04-05T06:00:00-07:00","endTime":"2020-04-05T18:00:00-07:00","isDaytime":true,"temperature":54,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"0 to 3 mph","windDirection":"N","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain,30?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain. Partly sunny, with a high near 54. Chance of precipitation is 30%. New rainfall amounts less than a tenth of an inch possible."},{"number":7,"name":"Sunday Night","startTime":"2020-04-05T18:00:00-07:00","endTime":"2020-04-06T06:00:00-07:00","isDaytime":false,"temperature":39,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"0 to 3 mph","windDirection":"N","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain,20?size=medium","shortForecast":"Slight Chance Light Rain","detailedForecast":"A slight chance of rain. Mostly cloudy, with a low around 39. Chance of precipitation is 20%."},{"number":8,"name":"Monday","startTime":"2020-04-06T06:00:00-07:00","endTime":"2020-04-06T18:00:00-07:00","isDaytime":true,"temperature":56,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NNW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain\/bkn?size=medium","shortForecast":"Slight Chance Light Rain then Partly Sunny","detailedForecast":"A slight chance of rain before 11am. Partly sunny, with a high near 56."},{"number":9,"name":"Monday Night","startTime":"2020-04-06T18:00:00-07:00","endTime":"2020-04-07T06:00:00-07:00","isDaytime":false,"temperature":38,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/sct?size=medium","shortForecast":"Partly Cloudy","detailedForecast":"Partly cloudy, with a low around 38."},{"number":10,"name":"Tuesday","startTime":"2020-04-07T06:00:00-07:00","endTime":"2020-04-07T18:00:00-07:00","isDaytime":true,"temperature":59,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"SW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/sct?size=medium","shortForecast":"Mostly Sunny","detailedForecast":"Mostly sunny, with a high near 59."},{"number":11,"name":"Tuesday Night","startTime":"2020-04-07T18:00:00-07:00","endTime":"2020-04-08T06:00:00-07:00","isDaytime":false,"temperature":40,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NNE","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/sct\/rain?size=medium","shortForecast":"Partly Cloudy then Slight Chance Light Rain","detailedForecast":"A slight chance of rain after 5am. Partly cloudy, with a low around 40."},{"number":12,"name":"Wednesday","startTime":"2020-04-08T06:00:00-07:00","endTime":"2020-04-08T18:00:00-07:00","isDaytime":true,"temperature":60,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"3 mph","windDirection":"WSW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain. Partly sunny, with a high near 60."},{"number":13,"name":"Wednesday Night","startTime":"2020-04-08T18:00:00-07:00","endTime":"2020-04-09T06:00:00-07:00","isDaytime":false,"temperature":41,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"2 mph","windDirection":"NNW","icon":"https:\/\/api.weather.gov\/icons\/land\/night\/rain?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain. Mostly cloudy, with a low around 41."},{"number":14,"name":"Thursday","startTime":"2020-04-09T06:00:00-07:00","endTime":"2020-04-09T18:00:00-07:00","isDaytime":true,"temperature":59,"temperatureUnit":"F","temperatureTrend":null,"windSpeed":"3 mph","windDirection":"WSW","icon":"https:\/\/api.weather.gov\/icons\/land\/day\/rain?size=medium","shortForecast":"Chance Light Rain","detailedForecast":"A chance of rain before 5pm, then a chance of rain showers. Partly sunny, with a high near 59."}]}"#.data(using: .utf8)! } diff --git a/Tests/NationalWeatherServiceTests/models/ForecastTests.swift b/Tests/NationalWeatherServiceTests/models/ForecastTests.swift index d30b61d..5334d0e 100644 --- a/Tests/NationalWeatherServiceTests/models/ForecastTests.swift +++ b/Tests/NationalWeatherServiceTests/models/ForecastTests.swift @@ -36,7 +36,7 @@ final class ForecastTests: XCTestCase { let forecast = try decoder.decode(Forecast.self, from: forecastData) XCTAssertEqual(forecast.generatedAt, iso8601.date(from: "2020-04-03T03:43:53+00:00")!) - XCTAssertEqual(forecast.updated, iso8601.date(from: "2020-04-02T23:05:37+00:00")!) + XCTAssertEqual(forecast.updateTime, iso8601.date(from: "2020-04-02T23:05:37+00:00")!) XCTAssertEqual(forecast.validTimes, DateInterval(start: iso8601.date(from: "2020-04-02T17:00:00+00:00")!, end: iso8601.date(from: "2020-04-10T13:00:00+00:00")!))