Skip to content
This repository was archived by the owner on Jun 19, 2026. It is now read-only.

Commit 4bcd753

Browse files
committed
Replace TestEnvironment.json with TestEnvironment.swift.
To workaround macOS 10.15 security issue preventing XCTestCases from reading files in ~/Documents.
1 parent f486426 commit 4bcd753

6 files changed

Lines changed: 61 additions & 45 deletions

File tree

‎Docs/API/Structs/ConnectionConfiguration.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ <h4>Declaration</h4>
246246
<section class="section">
247247
<div class="pointer"></div>
248248
<div class="abstract">
249-
<p>The name of the database of the Postgres server. Defaults to <code>postgres</code>.</p>
249+
<p>The name of the database on the Postgres server. Defaults to <code>postgres</code>.</p>
250250

251251
</div>
252252
<div class="declaration">

‎Docs/setting_up_a_postgres_database_for_testing.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ psql --host=127.0.0.1 --port=5432 --dbname=postgres --username=root < CreateTest
6666

6767
## Review the test suite configuration
6868

69-
The file `Tests/PostgresClientKitTests/TestEnvironment.json` describes the environment used by the PostgresClientKit test suite. Review its content and make any changes for your environment.
69+
The file `Tests/PostgresClientKitTests/TestEnvironment.swift` describes the environment used by the PostgresClientKit test suite. Review its content and make any changes for your environment.

‎Sources/PostgresClientKit/ConnectionConfiguration.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public struct ConnectionConfiguration {
5151
/// The timeout for socket operations, in seconds, or 0 for no timeout. Defaults to 0.
5252
public var socketTimeout: Int = 0
5353

54-
/// The name of the database of the Postgres server. Defaults to `postgres`.
54+
/// The name of the database on the Postgres server. Defaults to `postgres`.
5555
public var database = "postgres"
5656

5757
/// The Postgres username. Defaults to an empty string.

‎Tests/PostgresClientKitTests/PostgresClientKitTestCase.swift‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -79,37 +79,7 @@ class PostgresClientKitTestCase: XCTestCase {
7979
//
8080
// MARK: Connections
8181
//
82-
83-
/// An environment for testing PostgresClientKit.
84-
struct TestEnvironment: Codable {
85-
86-
var postgresHost: String
87-
var postgresPort: Int
88-
var postgresDatabase: String
89-
var terryUsername: String
90-
var terryPassword: String
91-
var charlieUsername: String
92-
var charliePassword: String
93-
var maryUsername: String
94-
var maryPassword: String
95-
96-
static let current: TestEnvironment = {
97-
98-
let url = URL(fileURLWithPath: #file)
99-
.appendingPathComponent("../TestEnvironment.json")
100-
.standardized
101-
102-
let environment: TestEnvironment
103-
104-
do {
105-
let data = try Data(contentsOf: url)
106-
return try JSONDecoder().decode(TestEnvironment.self, from: data)
107-
} catch {
108-
fatalError("Error reading TestEnvironment.json: \(error)")
109-
}
110-
}()
111-
}
112-
82+
11383
/// Creates a `ConnectionConfiguration` for Terry, authenticating by `Credential.trust`.
11484
///
11585
/// - Parameter ssl: whether to use SSL/TLS

‎Tests/PostgresClientKitTests/TestEnvironment.json‎

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// TestEnvironment.swift
3+
// PostgresClientKit
4+
//
5+
// Copyright 2020 David Pitfield and the PostgresClientKit contributors
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
20+
/// The configuration for unit testing.
21+
///
22+
/// Edit the properties' default values to reflect your environment.
23+
struct TestEnvironment {
24+
25+
/// The hostname or IP address of the Postgres server.
26+
let postgresHost = "127.0.0.1"
27+
28+
/// The port number of the Postgres server.
29+
let postgresPort = 5432
30+
31+
/// The name of the database on the Postgres server.
32+
let postgresDatabase = "postgresclientkittest"
33+
34+
/// The username of a Postgres user who can connect by `Credential.trust`.
35+
let terryUsername = "terry_postgresclientkittest"
36+
37+
/// The password of the Postgres user identified by `terryUsername`.
38+
let terryPassword = "welcome1"
39+
40+
/// The username of a Postgres user who can connect by `Credential.cleartextPassword`.
41+
let charlieUsername = "charlie_postgresclientkittest"
42+
43+
/// The password of the Postgres user identified by `charlieUsername`.
44+
let charliePassword = "welcome1"
45+
46+
/// The username of a Postgres user who can connect by `Credential.md5Password`.
47+
let maryUsername = "mary_postgresclientkittest"
48+
49+
/// The password of the Postgres user identified by `maryUsername`.
50+
let maryPassword = "welcome1"
51+
52+
53+
/// The current test environment.
54+
static let current = TestEnvironment()
55+
}
56+
57+
// EOF

0 commit comments

Comments
 (0)