Skip to content

Commit 872b86e

Browse files
committed
Cleanup
1 parent 8b98f2a commit 872b86e

File tree

2 files changed

+56
-36
lines changed

2 files changed

+56
-36
lines changed

Sources/App/Core/Dependencies/LoggerClient.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ extension LoggerClient {
4747
set(to: logger)
4848
}
4949
}
50+
51+
static var noop: Self {
52+
.init(log: { _, _ in }, set: { _ in })
53+
}
5054
}
5155
#endif
5256

Tests/AppTests/GitLiveTests.swift

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,72 +25,88 @@ import Testing
2525

2626
@Test func commitCount() async throws {
2727
try await withGitRepository(defaultDependencies) { path in
28-
try await XCTAssertEqualAsync(try await Git.commitCount(at: path), 57)
28+
let commitCount = try await Git.commitCount(at: path)
29+
#expect(commitCount == 57)
2930
}
3031
}
3132

3233
@Test func firstCommitDate() async throws {
3334
try await withGitRepository(defaultDependencies) { path in
34-
try await XCTAssertEqualAsync(try await Git.firstCommitDate(at: path),
35-
Date(timeIntervalSince1970: 1426918070)) // Sat, 21 March 2015
35+
let firstCommitDate = try await Git.firstCommitDate(at: path)
36+
#expect(firstCommitDate == Date(timeIntervalSince1970: 1426918070)) // Sat, 21 March 2015
3637
}
3738
}
3839

3940
@Test func lastCommitDate() async throws {
4041
try await withGitRepository(defaultDependencies) { path in
41-
try await XCTAssertEqualAsync(try await Git.lastCommitDate(at: path),
42-
Date(timeIntervalSince1970: 1554248253)) // Sat, 21 March 2015
42+
let lastCommitDate = try await Git.lastCommitDate(at: path)
43+
#expect(lastCommitDate == Date(timeIntervalSince1970: 1554248253)) // Sat, 21 March 2015
4344
}
4445
}
4546

4647
@Test func getTags() async throws {
4748
try await withGitRepository(defaultDependencies) { path in
48-
try await XCTAssertEqualAsync(
49-
try await Git.getTags(at: path),
50-
[.tag(0,2,0),
51-
.tag(0,2,1),
52-
.tag(0,2,2),
53-
.tag(0,2,3),
54-
.tag(0,2,4),
55-
.tag(0,2,5),
56-
.tag(0,3,0),
57-
.tag(0,4,0),
58-
.tag(0,4,1),
59-
.tag(0,4,2),
60-
.tag(0,5,0),
61-
.tag(0,5,1),
62-
.tag(0,5,2),
63-
.tag(.init(0,0,1), "v0.0.1"),
64-
.tag(.init(0,0,2), "v0.0.2"),
65-
.tag(.init(0,0,3), "v0.0.3"),
66-
.tag(.init(0,0,4), "v0.0.4"),
67-
.tag(.init(0,0,5), "v0.0.5"),
68-
.tag(.init(0,1,0), "v0.1.0")]
49+
let tags = try await Git.getTags(at: path)
50+
#expect(
51+
tags == [
52+
.tag(0,2,0),
53+
.tag(0,2,1),
54+
.tag(0,2,2),
55+
.tag(0,2,3),
56+
.tag(0,2,4),
57+
.tag(0,2,5),
58+
.tag(0,3,0),
59+
.tag(0,4,0),
60+
.tag(0,4,1),
61+
.tag(0,4,2),
62+
.tag(0,5,0),
63+
.tag(0,5,1),
64+
.tag(0,5,2),
65+
.tag(.init(0,0,1), "v0.0.1"),
66+
.tag(.init(0,0,2), "v0.0.2"),
67+
.tag(.init(0,0,3), "v0.0.3"),
68+
.tag(.init(0,0,4), "v0.0.4"),
69+
.tag(.init(0,0,5), "v0.0.5"),
70+
.tag(.init(0,1,0), "v0.1.0")
71+
]
6972
)
7073
}
7174
}
7275

7376
@Test func hasBranch() async throws {
7477
try await withGitRepository(defaultDependencies) { path in
75-
try await XCTAssertEqualAsync(try await Git.hasBranch(.branch("master"), at: path), true)
76-
try await XCTAssertEqualAsync(try await Git.hasBranch(.branch("main"), at: path), false)
78+
do {
79+
let hasBranch = try await Git.hasBranch(.branch("master"), at: path)
80+
#expect(hasBranch == true)
81+
}
82+
do {
83+
let hasBranch = try await Git.hasBranch(.branch("main"), at: path)
84+
#expect(hasBranch == false)
85+
}
7786
}
7887
}
7988

8089
@Test func revisionInfo() async throws {
8190
try await withGitRepository(defaultDependencies) { path in
82-
try await XCTAssertEqualAsync(try await Git.revisionInfo(.tag(0,5,2), at: path),
83-
.init(commit: "178566b112afe6bef3770678f1bbab6e5c626993",
84-
date: .init(timeIntervalSince1970: 1554248253)))
85-
try await XCTAssertEqualAsync(try await Git.revisionInfo(.branch("master"), at: path),
86-
.init(commit: "178566b112afe6bef3770678f1bbab6e5c626993",
87-
date: .init(timeIntervalSince1970: 1554248253)))
91+
do {
92+
let revisionInfo = try await Git.revisionInfo(.tag(0,5,2), at: path)
93+
#expect(revisionInfo
94+
== .init(commit: "178566b112afe6bef3770678f1bbab6e5c626993",
95+
date: .init(timeIntervalSince1970: 1554248253)))
96+
}
97+
do {
98+
let revisionInfo = try await Git.revisionInfo(.branch("master"), at: path)
99+
#expect(revisionInfo
100+
== .init(commit: "178566b112afe6bef3770678f1bbab6e5c626993",
101+
date: .init(timeIntervalSince1970: 1554248253)))
102+
}
88103
}
89104
}
90105

91106
@Test func shortlog() async throws {
92107
try await withGitRepository(defaultDependencies) { path in
93-
try await XCTAssertEqualAsync(try await Git.shortlog(at: path), """
108+
let shortlog = try await Git.shortlog(at: path)
109+
#expect(shortlog == """
94110
36\tNeil Pankey
95111
21\tJacob Williams
96112
""")
@@ -122,7 +138,7 @@ extension GitLiveTests {
122138
#endif
123139
var defaultDependencies: (inout DependencyValues) async throws -> Void {
124140
{
125-
$0.logger.log = { @Sendable _, _ in }
141+
$0.logger = .noop
126142
$0.shell = .liveValue
127143
}
128144
}

0 commit comments

Comments
 (0)