diff --git a/MastodonSDK.xctestplan b/MastodonSDK.xctestplan index 35fa310e5..bfea8bd74 100644 --- a/MastodonSDK.xctestplan +++ b/MastodonSDK.xctestplan @@ -47,6 +47,18 @@ } ] } + }, + { + "id" : "C229D9A6-6A83-4AF9-8A71-ADD1AD2AD9D8", + "name" : "mastodon.online", + "options" : { + "environmentVariableEntries" : [ + { + "key" : "domain", + "value" : "mastodon.online" + } + ] + } } ], "defaultOptions" : { @@ -54,8 +66,18 @@ }, "testTargets" : [ { + "skippedTests" : [ + "MastodonSDKTests\/testCreateAnAnpplication()", + "MastodonSDKTests\/testHomeTimeline()", + "MastodonSDKTests\/testOAuthAuthorize()", + "MastodonSDKTests\/testRetrieveAccountInfo()", + "MastodonSDKTests\/testRevokeToken()", + "MastodonSDKTests\/testUpdateCredentials()", + "MastodonSDKTests\/testVerifyAppCredentials()", + "MastodonSDKTests\/testVerifyCredentials()" + ], "target" : { - "containerPath" : "container:", + "containerPath" : "container:MastodonSDK", "identifier" : "MastodonSDKTests", "name" : "MastodonSDKTests" } diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift index 3154d63fa..56984f842 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Instance.swift @@ -13,7 +13,7 @@ extension Mastodon.Entity { /// - Since: 1.1.0 /// - Version: 3.3.0 /// # Last Update - /// 2021/2/5 + /// 2021/2/22 /// # Reference /// [Document](https://docs.joinmastodon.org/entities/instance/) public struct Instance: Codable { @@ -33,6 +33,7 @@ extension Mastodon.Entity { public let thumbnail: String? public let contactAccount: Account? + public let rules: [Rule]? enum CodingKeys: String, CodingKey { case uri @@ -48,8 +49,9 @@ extension Mastodon.Entity { case urls case statistics - case thumbnail = "thumbnail" + case thumbnail case contactAccount = "contact_account" + case rules } } } @@ -77,3 +79,10 @@ extension Mastodon.Entity.Instance { } } } + +extension Mastodon.Entity.Instance { + public struct Rule: Codable { + public let id: String + public let text: String + } +} diff --git a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift index 211c70d00..ee02cf073 100644 --- a/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift +++ b/MastodonSDK/Tests/MastodonSDKTests/API/MastodonSDK+API+Instance.swift @@ -37,5 +37,37 @@ extension MastodonSDKTests { wait(for: [theExpectation], timeout: 10.0) } + + func testInstanceRules() throws { + switch domain { + case "mastodon.online": break + default: return + } + + try _testInstanceRules(domain: domain) + } + + func _testInstanceRules(domain: String) throws { + let theExpectation = expectation(description: "Fetch Instance Infomation") + + Mastodon.API.Instance.instance(session: session, domain: domain) + .receive(on: DispatchQueue.main) + .sink { completion in + switch completion { + case .failure(let error): + XCTFail(error.localizedDescription) + case .finished: + break + } + } receiveValue: { response in + XCTAssertNotEqual(response.value.uri, "") + XCTAssert(!(response.value.rules ?? []).isEmpty) + print(response.value.rules?.sorted(by: { $0.id < $1.id }) ?? "") + theExpectation.fulfill() + } + .store(in: &disposeBag) + + wait(for: [theExpectation], timeout: 10.0) + } }