Skip to content

Commit 5e4ba0e

Browse files
committed
Update remaining test expectations
1 parent 7579697 commit 5e4ba0e

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

Sources/App/Core/Extensions/URL+ext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ extension URL {
1919
guard var components = URLComponents(url: self, resolvingAgainstBaseURL: false) else { return nil }
2020
if components.scheme == "http" { components.scheme = "https" }
2121
if !components.path.hasSuffix(".git") { components.path = components.path + ".git" }
22-
return components.url!
22+
return components.url
2323
}
2424
}

Tests/AppTests/CustomCollectionTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,27 +234,27 @@ class CustomCollectionTests: AppTestCase {
234234
// Test reconciliation of a custom collection against a list of package URLs
235235
let collection = CustomCollection(id: .id0, .init(name: "List", url: "https://github.com/foo/bar/list.json"))
236236
try await collection.save(on: app.db)
237-
try await Package(id: .id1, url: URL("a")).save(on: app.db)
238-
try await Package(id: .id2, url: URL("b")).save(on: app.db)
237+
try await Package(id: .id1, url: URL("https://github.com/a.git")).save(on: app.db)
238+
try await Package(id: .id2, url: URL("https://github.com/b.git")).save(on: app.db)
239239

240240
do { // Initial set of URLs
241241
// MUT
242-
try await collection.reconcile(on: app.db, packageURLs: [URL("a")])
242+
try await collection.reconcile(on: app.db, packageURLs: [URL("https://github.com/a.git")])
243243

244244
do { // validate
245245
let count = try await CustomCollectionPackage.query(on: app.db).count()
246246
XCTAssertEqual(count, 1)
247247
let collection = try await CustomCollection.find(.id0, on: app.db).unwrap()
248248
try await collection.$packages.load(on: app.db)
249-
XCTAssertEqual(collection.packages.map(\.url), ["a"])
249+
XCTAssertEqual(collection.packages.map(\.url), ["https://github.com/a.git"])
250250
}
251251
}
252252

253253
do { // Add more URLs
254254
// MUT
255255
try await collection.reconcile(on: app.db, packageURLs: [
256-
URL("a"),
257-
URL("b")
256+
URL("https://github.com/a.git"),
257+
URL("https://github.com/b.git")
258258
])
259259

260260
do { // validate
@@ -263,24 +263,24 @@ class CustomCollectionTests: AppTestCase {
263263
let collection = try await CustomCollection.find(.id0, on: app.db).unwrap()
264264
try await collection.$packages.load(on: app.db)
265265
XCTAssertEqual(collection.packages.map(\.url).sorted(), [
266-
"a",
267-
"b"
266+
"https://github.com/a.git",
267+
"https://github.com/b.git"
268268
])
269269
}
270270
}
271271

272272
do { // Remove URLs
273273
// MUT
274274
try await collection.reconcile(on: app.db, packageURLs: [
275-
URL("b")
275+
URL("https://github.com/b.git")
276276
])
277277

278278
do { // validate
279279
let count = try await CustomCollectionPackage.query(on: app.db).count()
280280
XCTAssertEqual(count, 1)
281281
let collection = try await CustomCollection.find(.id0, on: app.db).unwrap()
282282
try await collection.$packages.load(on: app.db)
283-
XCTAssertEqual(collection.packages.map(\.url), ["b"])
283+
XCTAssertEqual(collection.packages.map(\.url), ["https://github.com/b.git"])
284284
}
285285
}
286286
}

Tests/AppTests/ReconcilerTests.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ class ReconcilerTests: AppTestCase {
132132
func test_reconcileCustomCollections() async throws {
133133
// Test single custom collection reconciliation
134134
// setup
135-
var fullPackageList = [URL("a"), URL("b"), URL("c")]
135+
var fullPackageList = [URL("https://github.com/a.git"), URL("https://github.com/b.git"), URL("https://github.com/c.git")]
136136
for url in fullPackageList { try await Package(url: url).save(on: app.db) }
137137

138138
// Initial run
139139
try await withDependencies {
140-
$0.packageListRepository.fetchCustomCollection = { @Sendable _, _ in [URL("b")] }
140+
$0.packageListRepository.fetchCustomCollection = { @Sendable _, _ in [URL("https://github.com/b.git")] }
141141
} operation: {
142142
// MUT
143143
try await reconcileCustomCollection(client: app.client,
@@ -150,12 +150,12 @@ class ReconcilerTests: AppTestCase {
150150
XCTAssertEqual(count, 1)
151151
let collection = try await CustomCollection.query(on: app.db).first().unwrap()
152152
try await collection.$packages.load(on: app.db)
153-
XCTAssertEqual(collection.packages.map(\.url), ["b"])
153+
XCTAssertEqual(collection.packages.map(\.url), ["https://github.com/b.git"])
154154
}
155155

156156
// Reconcile again with an updated list of packages in the collection
157157
try await withDependencies {
158-
$0.packageListRepository.fetchCustomCollection = { @Sendable _, _ in [URL("c")] }
158+
$0.packageListRepository.fetchCustomCollection = { @Sendable _, _ in [URL("https://github.com/c.git")] }
159159
} operation: {
160160
// MUT
161161
try await reconcileCustomCollection(client: app.client,
@@ -168,14 +168,14 @@ class ReconcilerTests: AppTestCase {
168168
XCTAssertEqual(count, 1)
169169
let collection = try await CustomCollection.query(on: app.db).first().unwrap()
170170
try await collection.$packages.load(on: app.db)
171-
XCTAssertEqual(collection.packages.map(\.url), ["c"])
171+
XCTAssertEqual(collection.packages.map(\.url), ["https://github.com/c.git"])
172172
}
173173

174174
// Re-run after the single package in the list has been deleted in the full package list
175-
fullPackageList = [URL("a"), URL("b")]
176-
try await Package.query(on: app.db).filter(by: URL("c")).first()?.delete(on: app.db)
175+
fullPackageList = [URL("https://github.com/a.git"), URL("https://github.com/b.git")]
176+
try await Package.query(on: app.db).filter(by: URL("https://github.com/c.git")).first()?.delete(on: app.db)
177177
try await withDependencies {
178-
$0.packageListRepository.fetchCustomCollection = { @Sendable _, _ in [URL("c")] }
178+
$0.packageListRepository.fetchCustomCollection = { @Sendable _, _ in [URL("https://github.com/c.git")] }
179179
} operation: {
180180
// MUT
181181
try await reconcileCustomCollection(client: app.client,
@@ -195,7 +195,7 @@ class ReconcilerTests: AppTestCase {
195195
func test_reconcileCustomCollections_limit() async throws {
196196
// Test custom collection reconciliation size limit
197197
// setup
198-
let fullPackageList = (1...60).map { URL(string: "\($0)")! }
198+
let fullPackageList = (1...60).map { URL(string: "https://github.com/\($0).git")! }
199199
for url in fullPackageList { try await Package(url: url).save(on: app.db) }
200200

201201
try await withDependencies {
@@ -213,21 +213,21 @@ class ReconcilerTests: AppTestCase {
213213
let collection = try await CustomCollection.query(on: app.db).first().unwrap()
214214
try await collection.$packages.load(on: app.db)
215215
XCTAssertEqual(collection.packages.count, 50)
216-
XCTAssertEqual(collection.packages.first?.url, "1")
217-
XCTAssertEqual(collection.packages.last?.url, "50")
216+
XCTAssertEqual(collection.packages.first?.url, "https://github.com/1.git")
217+
XCTAssertEqual(collection.packages.last?.url, "https://github.com/50.git")
218218
}
219219
}
220220

221221
func test_reconcile() async throws {
222-
let fullPackageList = (1...3).map { URL(string: "\($0)")! }
222+
let fullPackageList = (1...3).map { URL(string: "https://github.com/\($0).git")! }
223223
struct TestError: Error { var message: String }
224224

225225
try await withDependencies {
226226
$0.packageListRepository.fetchPackageList = { @Sendable _ in fullPackageList }
227227
$0.packageListRepository.fetchPackageDenyList = { @Sendable _ in [] }
228228
$0.packageListRepository.fetchCustomCollection = { @Sendable _, url in
229229
if url == "collectionURL" {
230-
return [URL("2")]
230+
return [URL("https://github.com/2.git")]
231231
} else {
232232
throw TestError(message: "collection not found: \(url)")
233233
}
@@ -249,7 +249,7 @@ class ReconcilerTests: AppTestCase {
249249
XCTAssertEqual(collection.name, "List")
250250
XCTAssertEqual(collection.url, "collectionURL")
251251
try await collection.$packages.load(on: app.db)
252-
XCTAssertEqual(collection.packages.map(\.url), ["2"])
252+
XCTAssertEqual(collection.packages.map(\.url), ["https://github.com/2.git"])
253253
}
254254
}
255255

0 commit comments

Comments
 (0)