@@ -30,40 +30,6 @@ class PostgresKitTests: XCTestCase {
30
30
}
31
31
}
32
32
}
33
-
34
- func testCreateEnumWithBuilder( ) throws {
35
- let conn = try PostgresConnection . test ( on: self . eventLoop) . wait ( )
36
- defer { try ! conn. close ( ) . wait ( ) }
37
- let db = conn. sql ( )
38
-
39
- try db. create ( enum: " meal " , cases: " breakfast " , " lunch " , " dinner " ) . run ( ) . wait ( )
40
- try db. raw ( " DROP TYPE meal; " ) . run ( ) . wait ( )
41
-
42
- try db. create ( enum: SQLIdentifier ( " meal " ) , cases: " breakfast " , " lunch " , " dinner " ) . run ( ) . wait ( )
43
- try db. raw ( " DROP TYPE meal; " ) . run ( ) . wait ( )
44
- }
45
-
46
- func testDropEnumWithBuilder( ) throws {
47
- let conn = try PostgresConnection . test ( on: self . eventLoop) . wait ( )
48
- defer { try ! conn. close ( ) . wait ( ) }
49
- let db = conn. sql ( )
50
-
51
- // these two should work even if the type does not exist
52
- try db. drop ( type: " meal " ) . ifExists ( ) . run ( ) . wait ( )
53
- try db. drop ( type: " meal " ) . ifExists ( ) . cascade ( ) . run ( ) . wait ( )
54
-
55
- try db. create ( enum: " meal " , cases: " breakfast " , " lunch " , " dinner " ) . run ( ) . wait ( )
56
- try db. drop ( type: " meal " ) . ifExists ( ) . cascade ( ) . run ( ) . wait ( )
57
-
58
- try db. create ( enum: " meal " , cases: " breakfast " , " lunch " , " dinner " ) . run ( ) . wait ( )
59
- try db. drop ( type: " meal " ) . run ( ) . wait ( )
60
-
61
- try db. create ( enum: " meal " , cases: " breakfast " , " lunch " , " dinner " ) . run ( ) . wait ( )
62
- try db. drop ( type: SQLIdentifier ( " meal " ) ) . run ( ) . wait ( )
63
-
64
- try db. create ( enum: " meal " , cases: " breakfast " , " lunch " , " dinner " ) . run ( ) . wait ( )
65
- try db. drop ( type: " meal " ) . cascade ( ) . run ( ) . wait ( )
66
- }
67
33
68
34
func testLeak( ) throws {
69
35
struct Foo : Codable {
@@ -158,17 +124,44 @@ class PostgresKitTests: XCTestCase {
158
124
XCTAssertEqual ( test. baz, " baz " )
159
125
}
160
126
161
- private var eventLoopGroup : EventLoopGroup !
162
- private var eventLoop : EventLoop {
163
- return self . eventLoopGroup. next ( )
127
+ func testEnum( ) throws {
128
+ try self . benchmark. testEnum ( )
164
129
}
165
-
130
+
131
+ var db : SQLDatabase {
132
+ self . connection. sql ( )
133
+ }
134
+ var benchmark : SQLBenchmarker {
135
+ . init( on: self . db)
136
+ }
137
+ var eventLoop : EventLoop {
138
+ self . eventLoopGroup. next ( )
139
+ }
140
+
141
+ var eventLoopGroup : EventLoopGroup !
142
+ var connection : PostgresConnection !
143
+
166
144
override func setUp( ) {
167
- self . eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
145
+ XCTAssertTrue ( isLoggingConfigured)
146
+ self . eventLoopGroup = MultiThreadedEventLoopGroup ( numberOfThreads: 2 )
147
+ self . connection = try ! PostgresConnection . test (
148
+ on: self . eventLoopGroup. next ( )
149
+ ) . wait ( )
168
150
}
169
-
151
+
170
152
override func tearDown( ) {
171
- XCTAssertNoThrow ( try self . eventLoopGroup. syncShutdownGracefully ( ) )
153
+ try ! self . connection. close ( ) . wait ( )
154
+ self . connection = nil
155
+ try ! self . eventLoopGroup. syncShutdownGracefully ( )
172
156
self . eventLoopGroup = nil
173
157
}
174
158
}
159
+
160
+ let isLoggingConfigured : Bool = {
161
+ LoggingSystem . bootstrap { label in
162
+ var handler = StreamLogHandler . standardOutput ( label: label)
163
+ handler. logLevel = . debug
164
+ return handler
165
+ }
166
+ return true
167
+ } ( )
0 commit comments