Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import XCTest
@testable import PostgreSQLTests

XCTMain([
testCase(PostgreSQLConnectionTests.allTests),
])
import PostgreSQLTests

var tests = [XCTestCaseEntry]()
tests += PostgreSQLTests.__allTests()

XCTMain(tests)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import SQLBenchmark
import XCTest

class PostgreSQLConnectionTests: XCTestCase {
class ConnectionTests: XCTestCase {
struct VersionMetadata: Codable {
var version: String
}
Expand Down Expand Up @@ -97,7 +97,7 @@ class PostgreSQLConnectionTests: XCTestCase {
}

struct Hello: Codable, ReflectionDecodable, Equatable {
static func reflectDecoded() throws -> (PostgreSQLConnectionTests.Hello, PostgreSQLConnectionTests.Hello) {
static func reflectDecoded() throws -> (Hello, Hello) {
return (.init(message: "0"), .init(message: "1"))
}

Expand Down Expand Up @@ -621,24 +621,6 @@ class PostgreSQLConnectionTests: XCTestCase {
}
}

func testRangeSelectDecodePerformance() throws {
struct Series: Decodable {
var num: Int
}

let conn = try PostgreSQLConnection.makeTest()
measure {
let decoder = PostgreSQLRowDecoder()
do {
try conn.simpleQuery("SELECT * FROM generate_series(1, 10000) num") { row in
_ = try decoder.decode(Series.self, from: row)
}.wait()
} catch {
XCTFail("\(error)")
}
}
}

func testClosureRetainCycle() throws {
weak var connection: PostgreSQLConnection?
let request: EventLoopFuture<Void>
Expand Down Expand Up @@ -688,33 +670,6 @@ class PostgreSQLConnectionTests: XCTestCase {
XCTAssertEqual(polygon.polygon.points[3].y, 200)
}.wait()
}

static var allTests = [
("testBenchmark", testBenchmark),
("testVersion", testVersion),
("testSelectTypes", testSelectTypes),
("testStruct", testStruct),
("testNull", testNull),
("testGH24", testGH24),
("testURLParsing", testURLParsing),
("testGH46", testGH46),
("testDataDecoder", testDataDecoder),
("testRowDecoder", testRowDecoder),
("testRowCodableNested", testRowCodableNested),
("testRowCodableEmptyKeyed", testRowCodableEmptyKeyed),
("testRowCodableTypes", testRowCodableTypes),
("testTimeTz", testTimeTz),
("testListen", testListen),
("testSum", testSum),
("testOrderBy", testOrderBy),
("testInvalidDate", testInvalidDate),
("testEmptyArray", testEmptyArray),
("testZeroNumeric", testZeroNumeric),
("testNumericDecode", testNumericDecode),
("testClosureRetainCycle", testClosureRetainCycle),
("testGH125", testGH125),
("testPolygon", testPolygon),
]
}

extension PostgreSQLConnection {
Expand Down
22 changes: 22 additions & 0 deletions Tests/PostgreSQLTests/PerformanceTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@testable import PostgreSQL
import SQLBenchmark
import XCTest

class PerformanceTests: XCTestCase {
func testRangeSelectDecodePerformance() throws {
struct Series: Decodable {
var num: Int
}

let conn = try PostgreSQLConnection.makeTest()
measure {
do {
try conn.simpleQuery("SELECT * FROM generate_series(1, 10000) num") { row in
_ = try conn.decode(Series.self, from: row, table: nil)
}.wait()
} catch {
XCTFail("\(error)")
}
}
}
}
51 changes: 51 additions & 0 deletions Tests/PostgreSQLTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#if !canImport(ObjectiveC)
import XCTest

extension ConnectionTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__ConnectionTests = [
("testBenchmark", testBenchmark),
("testClosureRetainCycle", testClosureRetainCycle),
("testDataDecoder", testDataDecoder),
("testEmptyArray", testEmptyArray),
("testGH125", testGH125),
("testGH24", testGH24),
("testGH46", testGH46),
("testInvalidDate", testInvalidDate),
("testListen", testListen),
("testNull", testNull),
("testNumericDecode", testNumericDecode),
("testOrderBy", testOrderBy),
("testPolygon", testPolygon),
("testRowCodableEmptyKeyed", testRowCodableEmptyKeyed),
("testRowCodableNested", testRowCodableNested),
("testRowCodableTypes", testRowCodableTypes),
("testRowDecoder", testRowDecoder),
("testSelectTypes", testSelectTypes),
("testStruct", testStruct),
("testSum", testSum),
("testTimeTz", testTimeTz),
("testURLParsing", testURLParsing),
("testVersion", testVersion),
("testZeroNumeric", testZeroNumeric),
]
}

extension PerformanceTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__PerformanceTests = [
("testRangeSelectDecodePerformance", testRangeSelectDecodePerformance),
]
}

public func __allTests() -> [XCTestCaseEntry] {
return [
testCase(ConnectionTests.__allTests__ConnectionTests),
testCase(PerformanceTests.__allTests__PerformanceTests),
]
}
#endif
27 changes: 17 additions & 10 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ jobs:
- run:
name: Compile code with optimizations
command: swift build -c release
linux-performance:
docker:
- image: codevapor/swift:4.1
- image: circleci/postgres:9
name: psql
environment:
POSTGRES_USER: vapor_username
POSTGRES_DB: vapor_database
POSTGRES_PASSWORD: vapor_password
steps:
- checkout
- run:
name: swift test
command: swift test -c release -Xswiftc -enable-testing --filter "PostgreSQLTests.PerformanceTests"
workflows:
version: 2
tests:
Expand All @@ -121,13 +135,6 @@ workflows:
- 9-linux
- 9-linux-fluent
- linux-release
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
jobs:
- linux
notify:
webhooks:
- url: https://bot-gh.vapor.codes/circle/result