Skip to content

Commit 8de1b36

Browse files
committed
add compiler flags + update circle.yml
1 parent 0310ff7 commit 8de1b36

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

Tests/PostgreSQLTests/PostgreSQLConnectionTests.swift

+29-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ class PostgreSQLConnectionTests: XCTestCase {
88
}
99

1010
func testBenchmark() throws {
11+
#if !TEST_NO_GENERATED_AS_IDENTITY
1112
let conn = try PostgreSQLConnection.makeTest()
1213
let benchmarker = SQLBenchmarker(on: conn)
1314
try benchmarker.run()
15+
#endif
1416
}
1517

1618
func testVersion() throws {
1719
let client = try PostgreSQLConnection.makeTest()
1820
let results = try client.select().column(.function("version", [])).all(decoding: VersionMetadata.self).wait()
19-
XCTAssertTrue(results[0].version.contains("10."))
21+
XCTAssertTrue(results[0].version.contains("."))
2022
}
2123

2224
func testSelectTypes() throws {
@@ -113,10 +115,17 @@ class PostgreSQLConnectionTests: XCTestCase {
113115
defer {
114116
_ = try? client.drop(table: Foo.self).ifExists().run().wait()
115117
}
118+
#if TEST_NO_GENERATED_AS_IDENTITY
119+
try client.create(table: Foo.self)
120+
.column(for: \Foo.id, type: .bigserial, .primaryKey(identifier: nil))
121+
.column(for: \Foo.dict)
122+
.run().wait()
123+
#else
116124
try client.create(table: Foo.self)
117125
.column(for: \Foo.id, .primaryKey)
118126
.column(for: \Foo.dict)
119127
.run().wait()
128+
#endif
120129

121130
let hello = Hello(message: "Hello, world!")
122131
try client.insert(into: Foo.self).value(Foo(id: nil, dict: hello)).run().wait()
@@ -141,29 +150,45 @@ class PostgreSQLConnectionTests: XCTestCase {
141150
defer {
142151
try? conn.drop(table: Nulltest.self).ifExists().run().wait()
143152
}
153+
154+
#if TEST_NO_GENERATED_AS_IDENTITY
155+
try conn.create(table: Nulltest.self)
156+
.column(for: \Nulltest.i, type: .bigserial, .primaryKey(default: nil))
157+
.column(for: \Nulltest.d)
158+
.run().wait()
159+
#else
144160
try conn.create(table: Nulltest.self)
145161
.column(for: \Nulltest.i, .primaryKey)
146162
.column(for: \Nulltest.d)
147163
.run().wait()
164+
#endif
148165

149166
try conn.insert(into: Nulltest.self).value(Nulltest(i: nil, d: nil)).run().wait()
150167
}
151168

152169
func testGH24() throws {
153170
/// PREPARE
154171
let client = try PostgreSQLConnection.makeTest()
172+
173+
let idtype: String
174+
175+
#if TEST_NO_GENERATED_AS_IDENTITY
176+
idtype = "BIGSERIAL"
177+
#else
178+
idtype = "BIGINT GENERATED BY DEFAULT AS IDENTITY"
179+
#endif
155180

156181
/// CREATE
157182
let _ = try client.query("""
158183
CREATE TABLE "users" ("id" UUID PRIMARY KEY, "name" TEXT NOT NULL, "username" TEXT NOT NULL)
159184
""").wait()
160185
defer { _ = try! client.simpleQuery("DROP TABLE users").wait() }
161186
let _ = try client.query("""
162-
CREATE TABLE "acronyms" ("id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, "short" TEXT NOT NULL, "long" TEXT NOT NULL, "userID" UUID NOT NULL, FOREIGN KEY ("userID") REFERENCES "users" ("id"), FOREIGN KEY ("userID") REFERENCES "users" ("id"))
187+
CREATE TABLE "acronyms" ("id" \(idtype) PRIMARY KEY, "short" TEXT NOT NULL, "long" TEXT NOT NULL, "userID" UUID NOT NULL, FOREIGN KEY ("userID") REFERENCES "users" ("id"), FOREIGN KEY ("userID") REFERENCES "users" ("id"))
163188
""").wait()
164189
defer { _ = try! client.simpleQuery("DROP TABLE acronyms").wait() }
165190
let _ = try client.query("""
166-
CREATE TABLE "categories" ("id" BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, "name" TEXT NOT NULL)
191+
CREATE TABLE "categories" ("id" \(idtype) PRIMARY KEY, "name" TEXT NOT NULL)
167192
""").wait()
168193
defer { _ = try! client.simpleQuery("DROP TABLE categories").wait() }
169194
let _ = try client.query("""
@@ -542,7 +567,7 @@ extension PostgreSQLConnection {
542567
/// Creates a test connection.
543568
static func makeTest() throws -> PostgreSQLConnection {
544569
let transport: PostgreSQLConnection.TransportConfig
545-
#if TEST_SSL
570+
#if TEST_USE_UNVERIFIED_TLS
546571
transport = .unverifiedTLS
547572
#else
548573
transport = .cleartext

circle.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
command: swift build
4242
- run:
4343
name: Run unit tests
44-
command: swift test
44+
command: swift test -Xswiftc -DTEST_USE_UNVERIFIED_TLS
4545
10-linux-fluent:
4646
docker:
4747
- image: codevapor/swift:4.1
@@ -80,7 +80,7 @@ jobs:
8080
command: swift build
8181
- run:
8282
name: Run unit tests
83-
command: swift test
83+
command: swift test -Xswiftc -DTEST_NO_GENERATED_AS_IDENTITY
8484
9-linux-fluent:
8585
docker:
8686
- image: codevapor/swift:4.1

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
ports:
1111
- 5432:5432
1212
psql-9:
13-
image: postgres:10
13+
image: postgres:9
1414
environment:
1515
POSTGRES_USER: vapor_username
1616
POSTGRES_DB: vapor_database

0 commit comments

Comments
 (0)