|
15 | 15 | @testable import App |
16 | 16 |
|
17 | 17 | import SQLKit |
18 | | -import XCTest |
| 18 | +import Testing |
19 | 19 |
|
20 | 20 |
|
21 | | -class SQLKitExtensionTests: AppTestCase { |
| 21 | +@Suite struct SQLKitExtensionTests { |
22 | 22 |
|
23 | | - func test_OrderByGroup() throws { |
24 | | - let b = SQLOrderBy(SQLIdentifier("id"), .ascending) |
25 | | - .then(SQLIdentifier("foo"), .descending) |
26 | | - XCTAssertEqual(renderSQL(b), #""id" ASC, "foo" DESC"#) |
| 23 | + @Test func OrderByGroup() async throws { |
| 24 | + try await withApp { app in |
| 25 | + let b = SQLOrderBy(SQLIdentifier("id"), .ascending) |
| 26 | + .then(SQLIdentifier("foo"), .descending) |
| 27 | + #expect(app.db.renderSQL(b) == #""id" ASC, "foo" DESC"#) |
| 28 | + } |
27 | 29 | } |
28 | 30 |
|
29 | | - func test_OrderByGroup_complex() throws { |
30 | | - let packageName = SQLIdentifier("package_name") |
31 | | - let mergedTerms = SQLBind("a b") |
32 | | - let score = SQLIdentifier("score") |
33 | | - |
34 | | - let orderBy = SQLOrderBy(eq(lower(packageName), mergedTerms), .descending) |
35 | | - .then(score, .descending) |
36 | | - .then(packageName, .ascending) |
37 | | - XCTAssertEqual(renderSQL(orderBy), |
38 | | - #"LOWER("package_name") = $1 DESC, "score" DESC, "package_name" ASC"#) |
| 31 | + @Test func OrderByGroup_complex() async throws { |
| 32 | + try await withApp { app in |
| 33 | + let packageName = SQLIdentifier("package_name") |
| 34 | + let mergedTerms = SQLBind("a b") |
| 35 | + let score = SQLIdentifier("score") |
| 36 | + |
| 37 | + let orderBy = SQLOrderBy(eq(lower(packageName), mergedTerms), .descending) |
| 38 | + .then(score, .descending) |
| 39 | + .then(packageName, .ascending) |
| 40 | + #expect(app.db.renderSQL(orderBy) == #"LOWER("package_name") = $1 DESC, "score" DESC, "package_name" ASC"#) |
| 41 | + } |
39 | 42 | } |
40 | 43 |
|
41 | 44 | } |
0 commit comments