Skip to content

Commit

Permalink
Run processesRunBeforeServerStart after ServiceGroup in router XCT fr…
Browse files Browse the repository at this point in the history
…amework (#374)

* Run processesRunBeforeServerStart after ServiceGroup in router XCT framework

* Should also run processes if no services started
  • Loading branch information
adam-fowler authored Feb 5, 2024
1 parent 4a2a119 commit 6a678c9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Sources/HummingbirdXCT/HBXCTRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ struct HBXCTRouter<Responder: HBResponder>: HBXCTApplication where Responder.Con
logger: self.logger,
makeContext: self.makeContext
)
// run the runBeforeServer processes before we start testing
for process in self.processesRunBeforeServerStart {
try await process()
}
// if we have no services then just run test
if self.services.count == 0 {
// run the runBeforeServer processes before we run test closure.
for process in self.processesRunBeforeServerStart {
try await process()
}
return try await test(client)
}
// if we have services then setup task group with service group running in separate task from test
Expand All @@ -71,6 +71,11 @@ struct HBXCTRouter<Responder: HBResponder>: HBXCTApplication where Responder.Con
try await serviceGroup.run()
}
do {
// run the runBeforeServer processes before we run test closure. Need to do this
// after we have run the serviceGroup though
for process in self.processesRunBeforeServerStart {
try await process()
}
let value = try await test(client)
await serviceGroup.triggerGracefulShutdown()
return value
Expand Down

0 comments on commit 6a678c9

Please sign in to comment.