Skip to content

Commit 8c05a7c

Browse files
committed
Convert StatsTests
1 parent f27c0a6 commit 8c05a7c

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

Tests/AppTests/StatsTests.swift

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,34 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
@testable import App
16-
17-
import XCTVapor
15+
import Foundation
1816

17+
@testable import App
1918

20-
class StatsTests: AppTestCase {
21-
22-
func test_fetch() async throws {
23-
// setup
24-
do {
25-
let pkg = Package(id: UUID(), url: "1")
26-
try await pkg.save(on: app.db)
19+
import Testing
20+
21+
22+
@Suite struct StatsTests {
23+
24+
@Test func fetch() async throws {
25+
try await withApp { app in
26+
// setup
27+
do {
28+
let pkg = Package(id: UUID(), url: "1")
29+
try await pkg.save(on: app.db)
30+
}
31+
do {
32+
let pkg = Package(id: UUID(), url: "2")
33+
try await pkg.save(on: app.db)
34+
}
35+
try await Stats.refresh(on: app.db)
36+
37+
// MUT
38+
let res = try await Stats.fetch(on: app.db)
39+
40+
// validate
41+
#expect(res == .some(.init(packageCount: 2)))
2742
}
28-
do {
29-
let pkg = Package(id: UUID(), url: "2")
30-
try await pkg.save(on: app.db)
31-
}
32-
try await Stats.refresh(on: app.db)
33-
34-
// MUT
35-
let res = try await Stats.fetch(on: app.db)
36-
37-
// validate
38-
XCTAssertEqual(res, .some(.init(packageCount: 2)))
3943
}
4044

4145
}

0 commit comments

Comments
 (0)