restructure
Some checks failed
CI - Multi-Platform Native / Build iOS (RSSuper) (push) Has been cancelled
CI - Multi-Platform Native / Build macOS (push) Has been cancelled
CI - Multi-Platform Native / Build Android (push) Has been cancelled
CI - Multi-Platform Native / Build Linux (push) Has been cancelled
CI - Multi-Platform Native / Build Summary (push) Has been cancelled

This commit is contained in:
2026-03-30 16:39:18 -04:00
parent a8e07d52f0
commit c2e1622bd8
252 changed files with 4803 additions and 17165 deletions

View File

@@ -0,0 +1,116 @@
//
// FeedSubscriptionTests.swift
// RSSuperTests
//
// Created by Mike Freno on 3/29/26.
//
import XCTest
@testable import RSSuper
final class FeedSubscriptionTests: XCTestCase {
func testFeedSubscriptionEncodingDecoding() throws {
let subscription = FeedSubscription(
id: "sub-123",
url: "https://example.com/feed.xml",
title: "Example Feed",
category: "Tech",
enabled: true,
fetchInterval: 120,
createdAt: Date(timeIntervalSince1970: 1609459200),
updatedAt: Date(timeIntervalSince1970: 1609545600),
lastFetchedAt: Date(timeIntervalSince1970: 1609632000),
nextFetchAt: Date(timeIntervalSince1970: 1609718400),
error: nil,
httpAuth: HttpAuth(username: "user", password: "pass")
)
let data = try JSONEncoder().encode(subscription)
let decoded = try JSONDecoder().decode(FeedSubscription.self, from: data)
XCTAssertEqual(decoded.id, subscription.id)
XCTAssertEqual(decoded.url, subscription.url)
XCTAssertEqual(decoded.title, subscription.title)
XCTAssertEqual(decoded.category, subscription.category)
XCTAssertEqual(decoded.enabled, subscription.enabled)
XCTAssertEqual(decoded.fetchInterval, subscription.fetchInterval)
XCTAssertEqual(decoded.createdAt, subscription.createdAt)
XCTAssertEqual(decoded.updatedAt, subscription.updatedAt)
XCTAssertEqual(decoded.lastFetchedAt, subscription.lastFetchedAt)
XCTAssertEqual(decoded.nextFetchAt, subscription.nextFetchAt)
XCTAssertEqual(decoded.httpAuth?.username, subscription.httpAuth?.username)
XCTAssertEqual(decoded.httpAuth?.password, subscription.httpAuth?.password)
}
func testFeedSubscriptionOptionalProperties() throws {
let subscription = FeedSubscription(
id: "minimal-sub",
url: "https://example.com/minimal.xml",
title: "Minimal Feed"
)
XCTAssertNil(subscription.category)
XCTAssertNil(subscription.lastFetchedAt)
XCTAssertNil(subscription.nextFetchAt)
XCTAssertNil(subscription.error)
XCTAssertNil(subscription.httpAuth)
let data = try JSONEncoder().encode(subscription)
let decoded = try JSONDecoder().decode(FeedSubscription.self, from: data)
XCTAssertEqual(decoded.id, subscription.id)
XCTAssertEqual(decoded.enabled, true)
XCTAssertEqual(decoded.fetchInterval, 60)
}
func testFeedSubscriptionEquality() {
let sub1 = FeedSubscription(
id: "same-id",
url: "https://example.com/feed.xml",
title: "Same Title"
)
let sub2 = FeedSubscription(
id: "same-id",
url: "https://example.com/feed.xml",
title: "Same Title"
)
let sub3 = FeedSubscription(
id: "different-id",
url: "https://example.com/other.xml",
title: "Different Title"
)
XCTAssertEqual(sub1, sub2)
XCTAssertNotEqual(sub1, sub3)
}
func testHttpAuthEncodingDecoding() throws {
let auth = HttpAuth(username: "testuser", password: "testpass")
let data = try JSONEncoder().encode(auth)
let decoded = try JSONDecoder().decode(HttpAuth.self, from: data)
XCTAssertEqual(decoded.username, auth.username)
XCTAssertEqual(decoded.password, auth.password)
}
func testFeedSubscriptionDebugDescription() {
let subscription = FeedSubscription(
id: "debug-id",
url: "https://example.com/debug.xml",
title: "Debug Feed",
enabled: false,
fetchInterval: 30,
error: "Connection timeout"
)
let debugDesc = subscription.debugDescription
XCTAssertTrue(debugDesc.contains("debug-id"))
XCTAssertTrue(debugDesc.contains("Debug Feed"))
XCTAssertTrue(debugDesc.contains("30min"))
XCTAssertTrue(debugDesc.contains("Connection timeout"))
}
}