Packages/MoonriseKit/Tests/FeedsTests/LaunchTests.swift
21 lines · 1434 bytes
1 symbol in this file
1import Foundation
2import Testing
3@testable import Feeds
4
5@Test func decodesBackendLaunches() throws {
6 // Shape of GET /v1/launches from the local Worker, 2026-10-17.
7 let data = Data("""
8 {"fetchedAt":"2026-10-17T23:54:22.559Z","launches":[{"id":"3b430f81","name":"Falcon 9 Block 5 | Bandwagon 5","net":"2026-10-19T10:30:00Z",
9 "windowStart":"2026-10-19T10:30:00Z","windowEnd":"2026-10-19T11:30:00Z","status":"Go","statusName":"Go for Launch","provider":"SpaceX",
10 "rocket":"Falcon 9 Block 5","mission":"Bandwagon 5","missionType":"Dedicated Rideshare","missionDescription":"Rideshare.","orbit":"LEO",
11 "pad":"Space Launch Complex 40","location":"Cape Canaveral SFS, FL, USA","padLatitude":28.56194122,"padLongitude":-80.57735736},
12 {"id":"x","name":"Electron | HawkEye","net":"2026-10-21T05:00:00Z","windowStart":null,"windowEnd":null,"status":"TBC","statusName":"To Be Confirmed",
13 "provider":"Rocket Lab","rocket":"Electron","mission":null,"missionType":null,"missionDescription":null,"orbit":null,"pad":"LC-1B","location":"Mahia","padLatitude":null,"padLongitude":null}]}
14 """.utf8)
15 let list = try LaunchFeed.decode(data)
16 #expect(list.launches.count == 2)
17 #expect(list.launches[0].rocket == "Falcon 9 Block 5")
18 #expect(list.launches[0].net == (try Date("2026-10-19T10:30:00Z", strategy: .iso8601)))
19 #expect(list.launches[1].mission == nil)
20 #expect(list.fetchedAt != nil)
21}