Download this file
| 1 | import Foundation |
| 2 | import XCTest |
| 3 | import RastrilloApple |
| 4 | import RastrilloTestSupport |
| 5 | |
| 6 | @MainActor final class ScriptedPathSourceTests: XCTestCase { |
| 7 | func testDrivesConnectivity() async { |
| 8 | let source = ScriptedPathSource(.satisfied) |
| 9 | let connectivity = NativeConnectivity(source: source) |
| 10 | let origin = URL(string: "https://docs.example")! |
| 11 | for _ in 0..<200 where connectivity.path == nil { try? await Task.sleep(nanoseconds: 5_000_000) } |
| 12 | XCTAssertEqual(connectivity.path?.status, .satisfied, "The initial path was not delivered") |
| 13 | source.send(.unsatisfied) |
| 14 | for _ in 0..<200 where !connectivity.isOffline(origin) { try? await Task.sleep(nanoseconds: 5_000_000) } |
| 15 | XCTAssertTrue(connectivity.isOffline(origin)) |
| 16 | } |
| 17 | } |
| 18 | |