Test update/delete on merge provider index
This commit is contained in:
parent
259a7e18ca
commit
e10f33717d
|
@ -106,13 +106,18 @@ class ProviderRepository: Repository {
|
|||
|
||||
// update existing
|
||||
providers.forEach { dto in
|
||||
guard let name = dto.name else {
|
||||
return
|
||||
}
|
||||
guard let ws = index.metadata.first(where: {
|
||||
$0.name == dto.name
|
||||
$0.name == name
|
||||
}) else {
|
||||
// delete if not in new index
|
||||
pp_log.info("Deleting provider: \(name)")
|
||||
context.delete(dto)
|
||||
return
|
||||
}
|
||||
pp_log.info("Updating provider: \(name)")
|
||||
dto.fullName = ws.fullName
|
||||
dto.lastUpdate = Date()
|
||||
}
|
||||
|
|
|
@ -58,26 +58,26 @@ class ProvidersTests: XCTestCase {
|
|||
override func tearDown() {
|
||||
// manager.reset()
|
||||
}
|
||||
|
||||
// func testLoadBundledProviders() throws {
|
||||
// let exp = expectation(description: "Load bundle")
|
||||
//
|
||||
// manager.loadBundledProvidersPublisher(vpnProtocol: .openVPN)
|
||||
// .sink {
|
||||
// switch $0 {
|
||||
// case .finished:
|
||||
// exp.fulfill()
|
||||
//
|
||||
// case .failure(let error):
|
||||
// pp_log.error("Unable to load bundled providers: \(error)")
|
||||
// exp.fulfill()
|
||||
// }
|
||||
// } receiveValue: {
|
||||
// pp_log.debug("Loaded \($0.count) providers")
|
||||
// }.store(in: &cancellables)
|
||||
//
|
||||
// waitForExpectations(timeout: 10.0, handler: nil)
|
||||
// }
|
||||
|
||||
func testFetchLocalIndex() throws {
|
||||
let exp = expectation(description: "Local index")
|
||||
|
||||
manager.fetchProvidersIndexPublisher(priority: .bundle)
|
||||
.sink {
|
||||
switch $0 {
|
||||
case .finished:
|
||||
exp.fulfill()
|
||||
|
||||
case .failure(let error):
|
||||
pp_log.error("Unable to load remote provider: \(error)")
|
||||
exp.fulfill()
|
||||
}
|
||||
} receiveValue: {
|
||||
pp_log.debug("Loaded index")
|
||||
}.store(in: &cancellables)
|
||||
|
||||
waitForExpectations(timeout: 10.0, handler: nil)
|
||||
}
|
||||
|
||||
func testFetchRemoteIndex() throws {
|
||||
let exp = expectation(description: "Remote index")
|
||||
|
|
Loading…
Reference in New Issue