|
| 1 | +// Copyright Dave Verwer, Sven A. Schmidt, and other contributors. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +@testable import App |
| 16 | + |
| 17 | +import Dependencies |
| 18 | +import XCTVapor |
| 19 | + |
| 20 | + |
| 21 | +class LiveTests: XCTestCase { |
| 22 | + |
| 23 | + func test_Mastodon_post() async throws { |
| 24 | + // Only run this test manually to confirm posting works |
| 25 | + try XCTSkipIf(true) |
| 26 | + |
| 27 | + try await withDependencies { |
| 28 | + $0.environment.mastodonCredentials = { .dev } |
| 29 | + $0.httpClient = .liveValue |
| 30 | + $0.uuid = .init(UUID.init) |
| 31 | + } operation: { |
| 32 | + let message = Social.versionUpdateMessage( |
| 33 | + packageName: "packageName", |
| 34 | + repositoryOwnerName: "owner", |
| 35 | + url: "http://localhost:8080/owner/SomePackage", |
| 36 | + version: .init(2, 6, 4), |
| 37 | + summary: "Testing, testing αβγ ÄÖÜß 🔤 ✅", |
| 38 | + maxLength: Social.postMaxLength |
| 39 | + ) |
| 40 | + |
| 41 | + try await Mastodon.post(message: message) |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +extension Mastodon.Credentials { |
| 49 | + // https://mas.to/@spi_test |
| 50 | + static var dev: Self? { |
| 51 | + guard let accessToken = Environment.get("DEV_MASTODON_ACCESS_TOKEN") else { return nil } |
| 52 | + return .init(accessToken: accessToken) |
| 53 | + } |
| 54 | +} |
0 commit comments