@@ -538,6 +538,7 @@ class PackageController_routesTests: SnapshotTestCase {
538538 // /owner/package/documentation/~ + various path elements
539539 try await withDependencies {
540540 $0. environment. awsDocsBucket = { " docs-bucket " }
541+ $0. environment. currentReferenceCache = { nil }
541542 } operation: {
542543 // setup
543544 let pkg = try await savePackage ( on: app. db, " 1 " )
@@ -620,6 +621,7 @@ class PackageController_routesTests: SnapshotTestCase {
620621 // /owner/package/documentation/~ + various path elements
621622 try await withDependencies {
622623 $0. environment. awsDocsBucket = { " docs-bucket " }
624+ $0. environment. currentReferenceCache = { nil }
623625 } operation: {
624626 // setup
625627 let pkg = try await savePackage ( on: app. db, " 1 " )
@@ -905,6 +907,7 @@ class PackageController_routesTests: SnapshotTestCase {
905907 func test_documentation_current_css( ) async throws {
906908 try await withDependencies {
907909 $0. environment. awsDocsBucket = { " docs-bucket " }
910+ $0. environment. currentReferenceCache = { nil }
908911 } operation: {
909912 // setup
910913 Current . fetchDocumentation = { _, uri in
@@ -967,6 +970,7 @@ class PackageController_routesTests: SnapshotTestCase {
967970 func test_documentation_current_js( ) async throws {
968971 try await withDependencies {
969972 $0. environment. awsDocsBucket = { " docs-bucket " }
973+ $0. environment. currentReferenceCache = { nil }
970974 } operation: {
971975 // setup
972976 Current . fetchDocumentation = { _, uri in
@@ -1029,6 +1033,7 @@ class PackageController_routesTests: SnapshotTestCase {
10291033 func test_documentation_current_data( ) async throws {
10301034 try await withDependencies {
10311035 $0. environment. awsDocsBucket = { " docs-bucket " }
1036+ $0. environment. currentReferenceCache = { nil }
10321037 } operation: {
10331038 // setup
10341039 Current . fetchDocumentation = { _, uri in
@@ -1146,6 +1151,7 @@ class PackageController_routesTests: SnapshotTestCase {
11461151 // Ensure references are path encoded
11471152 try await withDependencies {
11481153 $0. environment. awsDocsBucket = { " docs-bucket " }
1154+ $0. environment. currentReferenceCache = { nil }
11491155 } operation: {
11501156 // setup
11511157 let pkg = try await savePackage ( on: app. db, " 1 " )
@@ -1209,6 +1215,7 @@ class PackageController_routesTests: SnapshotTestCase {
12091215 func test_documentation_routes_tutorials( ) async throws {
12101216 try await withDependencies {
12111217 $0. environment. awsDocsBucket = { " docs-bucket " }
1218+ $0. environment. currentReferenceCache = { nil }
12121219 } operation: {
12131220 // setup
12141221 let pkg = try await savePackage ( on: app. db, " 1 " )
@@ -1478,6 +1485,7 @@ class PackageController_routesTests: SnapshotTestCase {
14781485 // https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2288
14791486 try await withDependencies {
14801487 $0. environment. awsDocsBucket = { " docs-bucket " }
1488+ $0. environment. currentReferenceCache = { . live }
14811489 } operation: {
14821490 // setup
14831491 let pkg = try await savePackage ( on: app. db, " https://github.com/foo/bar " . url, processingStage: . ingestion)
@@ -1555,28 +1563,31 @@ class PackageController_routesTests: SnapshotTestCase {
15551563
15561564 func test_getDocRoute_documentation_current( ) async throws {
15571565 nonisolated ( unsafe) let cache = CurrentReferenceCache ( )
1558- Current . currentReferenceCache = { cache }
1559- // owner/repo/~/documentation/archive
1560- let req = Request ( application: app, url: " " , on: app. eventLoopGroup. next ( ) )
1561- req. parameters. set ( " owner " , to: " owner " )
1562- req. parameters. set ( " repository " , to: " repo " )
1563- req. parameters. set ( " reference " , to: " ~ " )
1564- req. parameters. set ( " archive " , to: " archive " )
1566+ try await withDependencies {
1567+ $0. environment. currentReferenceCache = { cache }
1568+ } operation: {
1569+ // owner/repo/~/documentation/archive
1570+ let req = Request ( application: app, url: " " , on: app. eventLoopGroup. next ( ) )
1571+ req. parameters. set ( " owner " , to: " owner " )
1572+ req. parameters. set ( " repository " , to: " repo " )
1573+ req. parameters. set ( " reference " , to: " ~ " )
1574+ req. parameters. set ( " archive " , to: " archive " )
15651575
1566- do { // No cache value available and we've not set up the db with a record to be found -> notFound must be raised
1567- _ = try await req. getDocRoute ( fragment: . documentation)
1568- XCTFail ( " expected a .notFound error " )
1569- } catch let error as Abort where error. status == . notFound {
1570- // expected error
1571- } catch {
1572- XCTFail ( " unexpected error: \( error) " )
1573- }
1576+ do { // No cache value available and we've not set up the db with a record to be found -> notFound must be raised
1577+ _ = try await req. getDocRoute ( fragment: . documentation)
1578+ XCTFail ( " expected a .notFound error " )
1579+ } catch let error as Abort where error. status == . notFound {
1580+ // expected error
1581+ } catch {
1582+ XCTFail ( " unexpected error: \( error) " )
1583+ }
15741584
1575- cache [ owner: " owner " , repository: " repo " ] = " 1.2.3 "
1585+ cache [ owner: " owner " , repository: " repo " ] = " 1.2.3 "
15761586
1577- do { // Now with the cache in place this resolves
1578- let route = try await req. getDocRoute ( fragment: . documentation)
1579- XCTAssertEqual ( route, . init( owner: " owner " , repository: " repo " , docVersion: . current( referencing: " 1.2.3 " ) , fragment: . documentation, pathElements: [ " archive " ] ) )
1587+ do { // Now with the cache in place this resolves
1588+ let route = try await req. getDocRoute ( fragment: . documentation)
1589+ XCTAssertEqual ( route, . init( owner: " owner " , repository: " repo " , docVersion: . current( referencing: " 1.2.3 " ) , fragment: . documentation, pathElements: [ " archive " ] ) )
1590+ }
15801591 }
15811592 }
15821593
0 commit comments