Skip to content

Commit a763261

Browse files
committed
test example
1 parent b584d35 commit a763261

File tree

2 files changed

+70
-16
lines changed

2 files changed

+70
-16
lines changed

Sources/StructuredQueriesTestSupport/AssertQuery.swift

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,24 @@ public func assertQuery<each V: QueryRepresentable, S: Statement<(repeat each V)
9797
line: line,
9898
column: column
9999
)
100-
} else if results != nil {
101-
assertInlineSnapshot(
102-
of: table,
103-
as: .lines,
104-
message: "Results expected to be empty",
105-
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
106-
trailingClosureLabel: "results",
107-
trailingClosureOffset: snapshotTrailingClosureOffset + 1
108-
),
109-
matches: results,
110-
fileID: fileID,
111-
file: filePath,
112-
function: function,
113-
line: line,
114-
column: column
115-
)
116100
}
101+
// } else if results != nil {
102+
// assertInlineSnapshot(
103+
// of: table,
104+
// as: .lines,
105+
// message: "Results expected to be empty",
106+
// syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
107+
// trailingClosureLabel: "results",
108+
// trailingClosureOffset: snapshotTrailingClosureOffset + 1
109+
// ),
110+
// matches: results,
111+
// fileID: fileID,
112+
// file: filePath,
113+
// function: function,
114+
// line: line,
115+
// column: column
116+
// )
117+
// }
117118
} catch {
118119
assertInlineSnapshot(
119120
of: error.localizedDescription,

Tests/StructuredQueriesTests/WhereTests.swift

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,59 @@ extension SnapshotTests {
4040
}
4141
}
4242

43+
// This test should not succeed
44+
@Test func emptyResults() {
45+
assertQuery(
46+
Reminder.where(\.isCompleted).and(Reminder.where(\.isFlagged))
47+
) {
48+
"""
49+
SELECT "reminders"."id", "reminders"."assignedUserID", "reminders"."dueDate", "reminders"."isCompleted", "reminders"."isFlagged", "reminders"."notes", "reminders"."priority", "reminders"."remindersListID", "reminders"."title"
50+
FROM "reminders"
51+
WHERE ("reminders"."isCompleted") AND ("reminders"."isFlagged")
52+
"""
53+
} results: {
54+
"""
55+
┌────────────────────────────────────────────┐
56+
│ Reminder( │
57+
│ id: 4, │
58+
│ assignedUserID: nil, │
59+
│ dueDate: Date(2000-06-25T00:00:00.000Z), │
60+
│ isCompleted: true, │
61+
│ isFlagged: false, │
62+
│ notes: "", │
63+
│ priority: nil, │
64+
│ remindersListID: 1, │
65+
│ title: "Take a walk"
66+
│ ) │
67+
├────────────────────────────────────────────┤
68+
│ Reminder( │
69+
│ id: 7, │
70+
│ assignedUserID: nil, │
71+
│ dueDate: Date(2000-12-30T00:00:00.000Z), │
72+
│ isCompleted: true, │
73+
│ isFlagged: false, │
74+
│ notes: "", │
75+
│ priority: .low, │
76+
│ remindersListID: 2, │
77+
│ title: "Get laundry"
78+
│ ) │
79+
├────────────────────────────────────────────┤
80+
│ Reminder( │
81+
│ id: 10, │
82+
│ assignedUserID: nil, │
83+
│ dueDate: Date(2000-12-30T00:00:00.000Z), │
84+
│ isCompleted: true, │
85+
│ isFlagged: false, │
86+
│ notes: "", │
87+
│ priority: .medium, │
88+
│ remindersListID: 3, │
89+
│ title: "Send weekly emails"
90+
│ ) │
91+
└────────────────────────────────────────────┘
92+
"""
93+
}
94+
}
95+
4396
@Test func or() {
4497
assertQuery(
4598
Reminder.where(\.isCompleted).or(Reminder.where(\.isFlagged))

0 commit comments

Comments
 (0)