-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathFluentSQLiteDriverTests.swift
172 lines (136 loc) · 4.11 KB
/
FluentSQLiteDriverTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import FluentBenchmark
import FluentSQLiteDriver
import XCTest
import Logging
final class FluentSQLiteDriverTests: XCTestCase {
func testAll() throws {
try self.benchmarker.testAll()
}
func testCreate() throws {
try self.benchmarker.testCreate()
}
func testRead() throws {
try self.benchmarker.testRead()
}
func testUpdate() throws {
try self.benchmarker.testUpdate()
}
func testDelete() throws {
try self.benchmarker.testDelete()
}
func testEagerLoadChildren() throws {
try self.benchmarker.testEagerLoadChildren()
}
func testEagerLoadParent() throws {
try self.benchmarker.testEagerLoadParent()
}
func testEagerLoadParentJoin() throws {
try self.benchmarker.testEagerLoadParentJoin()
}
func testEagerLoadParentJSON() throws {
try self.benchmarker.testEagerLoadParentJSON()
}
func testEagerLoadChildrenJSON() throws {
try self.benchmarker.testEagerLoadChildrenJSON()
}
func testMigrator() throws {
try self.benchmarker.testMigrator()
}
func testMigratorError() throws {
try self.benchmarker.testMigratorError()
}
func testJoin() throws {
try self.benchmarker.testJoin()
}
func testBatchCreate() throws {
try self.benchmarker.testBatchCreate()
}
func testBatchUpdate() throws {
try self.benchmarker.testBatchUpdate()
}
func testNestedModel() throws {
try self.benchmarker.testNestedModel()
}
func testAggregates() throws {
try self.benchmarker.testAggregates()
}
func testIdentifierGeneration() throws {
try self.benchmarker.testIdentifierGeneration()
}
func testNullifyField() throws {
try self.benchmarker.testNullifyField()
}
func testChunkedFetch() throws {
try self.benchmarker.testChunkedFetch()
}
func testUniqueFields() throws {
try self.benchmarker.testUniqueFields()
}
func testAsyncCreate() throws {
try self.benchmarker.testAsyncCreate()
}
func testSoftDelete() throws {
try self.benchmarker.testSoftDelete()
}
func testTimestampable() throws {
try self.benchmarker.testTimestampable()
}
func testLifecycleHooks() throws {
try self.benchmarker.testLifecycleHooks()
}
func testSort() throws {
try self.benchmarker.testSort()
}
func testUUIDModel() throws {
try self.benchmarker.testUUIDModel()
}
func testNewModelDecode() throws {
try self.benchmarker.testNewModelDecode()
}
func testSiblingsAttach() throws {
try self.benchmarker.testSiblingsAttach()
}
func testSiblingsEagerLoad() throws {
try self.benchmarker.testSiblingsEagerLoad()
}
func testMultipleJoinSameTable() throws {
try self.benchmarker.testMultipleJoinSameTable()
}
func testOptionalParent() throws {
try self.benchmarker.testOptionalParent()
}
var benchmarker: FluentBenchmarker {
return .init(database: self.dbs.default())
}
var threadPool: NIOThreadPool!
var eventLoopGroup: EventLoopGroup!
var dbs: Databases!
override func setUp() {
XCTAssert(isLoggingConfigured)
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
self.threadPool = .init(numberOfThreads: 2)
self.dbs = Databases()
self.dbs.sqlite(
configuration: .init(storage: .memory),
threadPool: self.threadPool,
poolConfiguration: .init(maxConnections: 8),
on: self.eventLoopGroup
)
}
override func tearDown() {
self.dbs.shutdown()
self.dbs = nil
try! self.threadPool.syncShutdownGracefully()
self.threadPool = nil
try! self.eventLoopGroup.syncShutdownGracefully()
self.eventLoopGroup = nil
}
}
let isLoggingConfigured: Bool = {
LoggingSystem.bootstrap { label in
var handler = StreamLogHandler.standardOutput(label: label)
handler.logLevel = .debug
return handler
}
return true
}()