Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vox-humana committed Oct 12, 2024
1 parent 56d0692 commit 1a510de
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 193 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on: [push]
jobs:
build-mac:
# https://github.com/actions/runner-images/tree/main/images/macos
runs-on: macos-12
runs-on: macos-15
env:
DEVELOPER_DIR: /Applications/Xcode_14.2.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build the app
run: |
Expand All @@ -21,7 +21,7 @@ jobs:
run: swift test

- name: Archive binary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: postman-mac
path: Postman
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build the app
run: |
Expand All @@ -41,7 +41,7 @@ jobs:
run: swift test

- name: Archive binary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: postman-linux
path: Postman
21 changes: 15 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
}
},
{
"identity" : "swift-snapshot-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing.git",
"state" : {
"revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334",
"version" : "1.11.0"
"revision" : "7b0bbbae90c41f848f90ac7b4df6c4f50068256d",
"version" : "1.17.5"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
}
],
Expand Down
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ let package = Package(
.executable(name: "Postman", targets: ["Postman"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.2"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.1"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
.package(url: "https://github.com/AlwaysRightInstitute/mustache.git", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.11.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.17.5"),
],
targets: [
.executableTarget(
Expand All @@ -29,7 +29,7 @@ let package = Package(
name: "PostmanTests",
dependencies: [
"Postman",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
],
resources: [
.copy("feed.json"),
Expand Down
22 changes: 0 additions & 22 deletions Sources/Postman/AsyncParsableCommand.swift

This file was deleted.

6 changes: 3 additions & 3 deletions Sources/Postman/Postman.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct Postman: AsyncParsableCommand {
)
var translator: Job.Watson?

mutating func runAsync() async throws {
func run() async throws {
let storageURL = storageFile.map(URL.init(fileURLWithPath:))
var storage = storageURL
.flatMap { try? Data(contentsOf: $0) }
Expand Down Expand Up @@ -123,11 +123,11 @@ extension Job {

private extension Review.MustacheKeys {
static var allSupportedKeys: String {
Self.allCases.map(\.rawValue).joined(separator: ", ")
allCases.map(\.rawValue).joined(separator: ", ")
}
}

extension URL: ExpressibleByArgument {
extension URL: @retroactive ExpressibleByArgument {
public init?(argument: String) {
self.init(string: argument)
}
Expand Down
91 changes: 53 additions & 38 deletions Tests/PostmanTests/FormattingTests.swift

Large diffs are not rendered by default.

124 changes: 52 additions & 72 deletions Tests/PostmanTests/JobTests.swift
Original file line number Diff line number Diff line change
@@ -1,107 +1,87 @@
import Foundation
@testable import Postman
import XCTest
import Testing
#if canImport(FoundationNetworking)
import struct FoundationNetworking.URLRequest
#endif

final class JobTests: XCTestCase {
func testMultipleJobs() throws {
struct JobTests {
@Test func multipleJobs() async throws {
let appId = "42"
let codeAU = CountryCode.AU
let codeNZ = CountryCode.NZ
let postURL = URL(string: "POST")!
let transport = MockTransport(
let transport = try MockTransport(
[
postURL: "",
URL.reviewFeedURL(for: appId, countryCode: codeAU): try ReviewsFeed.testFeed(for: "feed"),
URL.reviewFeedURL(for: appId, countryCode: codeNZ): try ReviewsFeed.testFeed(for: "feed"),
URL.reviewFeedURL(for: appId, countryCode: codeAU): ReviewsFeed.testFeed(for: "feed"),
URL.reviewFeedURL(for: appId, countryCode: codeNZ): ReviewsFeed.testFeed(for: "feed"),
]
)
// Can't use `async` annotation for test method on Linux
// https://bugs.swift.org/browse/SR-15230
let expectation = XCTestExpectation(description: "job")
Task {
var storage: SentStorage = [.AU: 6_062_329_274]
await Job.runJobs(
appId: appId,
countryCodes: [codeAU, codeNZ],
mustacheTemplate: "{{stars}}",
postURL: postURL,
translator: nil,
transport: transport,
storage: &storage
)
XCTAssertEqual(transport.postRequestsCount, 3)
XCTAssertEqual(storage, [.AU: 6_184_999_566, .NZ: 6_184_999_566])
expectation.fulfill()
}
wait(for: [expectation], timeout: 60)
var storage: SentStorage = [.AU: 6_062_329_274]
await Job.runJobs(
appId: appId,
countryCodes: [codeAU, codeNZ],
mustacheTemplate: "{{stars}}",
postURL: postURL,
translator: nil,
transport: transport,
storage: &storage
)
#expect(transport.postRequestsCount == 3)
#expect(storage == [.AU: 6_184_999_566, .NZ: 6_184_999_566])
}

func testJob() throws {
@Test func job() async throws {
let appId = "42"
let code = CountryCode.AU
let postURL = URL(string: "POST")!
let template = """
{"text": "{{stars}}\n{{message}}\n{{contry_flag}} {{author}}"}
"""
let transport = MockTransport(
let transport = try MockTransport(
[
postURL: "",
URL.reviewFeedURL(for: appId, countryCode: code): try ReviewsFeed.testFeed(for: "feed"),
URL.reviewFeedURL(for: appId, countryCode: code): ReviewsFeed.testFeed(for: "feed"),
]
)
// Can't use `async` annotation for test method on Linux
// https://bugs.swift.org/browse/SR-15230
let expectation = XCTestExpectation(description: "job")
Task {
var storage = SentStorage()
await Job.runJobs(
appId: appId,
countryCodes: [code],
mustacheTemplate: template,
postURL: postURL,
translator: nil,
transport: transport,
storage: &storage
)
XCTAssertEqual(storage, [.AU: 6_184_999_566])
let request = try XCTUnwrap(transport.lastPostRequest)
XCTAssertEqual(request, """
{\"text\": \"★★★★★\nGitHub is by far the best, not only because it’s the only one out there to offer a great mobile app (where you can even browse the source code) but also because its UI is sooo gooood!!!!!\n ph7enry\"}
""")
expectation.fulfill()
}
wait(for: [expectation], timeout: 60)
var storage = SentStorage()
await Job.runJobs(
appId: appId,
countryCodes: [code],
mustacheTemplate: template,
postURL: postURL,
translator: nil,
transport: transport,
storage: &storage
)
#expect(storage == [.AU: 6_184_999_566])
let request = try #require(transport.lastPostRequest)
#expect(request == """
{\"text\": \"★★★★★\nGitHub is by far the best, not only because it’s the only one out there to offer a great mobile app (where you can even browse the source code) but also because its UI is sooo gooood!!!!!\n ph7enry\"}
""")
}

func testPostingFailure() throws {
@Test func postingFailure() async throws {
let appId = "42"
let code = CountryCode.AU
let feedURL = URL.reviewFeedURL(for: appId, countryCode: code)
let transport = MockTransport(
let transport = try MockTransport(
[
feedURL: try ReviewsFeed.testFeed(for: "feed"),
feedURL: ReviewsFeed.testFeed(for: "feed"),
]
)
// Can't use `async` annotation for test method on Linux
// https://bugs.swift.org/browse/SR-15230
let expectation = XCTestExpectation(description: "job")
Task {
var storage = SentStorage()
await Job.runJobs(
appId: appId,
countryCodes: [code],
mustacheTemplate: "",
postURL: URL(string: "POST")!,
translator: nil,
transport: transport,
storage: &storage
)
XCTAssertTrue(storage.isEmpty)
expectation.fulfill()
}
wait(for: [expectation], timeout: 60)
var storage = SentStorage()
await Job.runJobs(
appId: appId,
countryCodes: [code],
mustacheTemplate: "",
postURL: URL(string: "POST")!,
translator: nil,
transport: transport,
storage: &storage
)
#expect(storage.isEmpty)
}
}

Expand Down Expand Up @@ -139,7 +119,7 @@ private final class MockTransport: NetworkTransport {

extension ReviewsFeed {
static func testFeed(for resource: String) throws -> Self {
let url = try XCTUnwrap(Bundle.module.url(forResource: resource, withExtension: "json"))
let url = try #require(Bundle.module.url(forResource: resource, withExtension: "json"))
let data = try Data(contentsOf: url)
return try JSONDecoder().decode(ReviewsFeed.self, from: data)
}
Expand Down
Loading

0 comments on commit 1a510de

Please sign in to comment.