// // ServerConnectionErrorTests.swift // // Copyright 2026 Brendan Szymanski // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // SPDX-License-Identifier: GPL-3.0-or-later // import Foundation import Testing @testable import LuminateCore /// Covers the human-readable messages for each `ServerConnectionError` case. @Suite struct ServerConnectionErrorTests { @Test("Unreachable joins every attempted URL with 'or'") func unreachableJoinsAttemptedURLs() { let a = URL(string: "http://a.test")! let b = URL(string: "http://b.test")! #expect( ServerConnectionError.unreachable(attempted: [a, b]).message == "Could not reach a server at http://a.test or http://b.test.") } @Test("Rejected includes the URL and the detail text") func rejectedIncludesURLAndDetail() { #expect( ServerConnectionError.rejected(url: URL(string: "http://host")!, detail: "not JSON").message == "http://host answered, but not as a Jellyfin server: not JSON") } @Test("A missing product name renders as an unknown product") func missingProductNameRendersUnknown() { #expect( ServerConnectionError.notJellyfin(url: URL(string: "http://host")!, productName: nil).message == "http://host is running an unknown product, not Jellyfin.") } @Test("A named product renders its own name") func namedProductRendersOwnName() { #expect( ServerConnectionError.notJellyfin(url: URL(string: "http://host")!, productName: "Emby").message == "http://host is running Emby, not Jellyfin.") } }