Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ConnectivityResponseValidator protocol and customValidator property #1

Closed
wants to merge 3 commits into from

Conversation

benasher44
Copy link
Owner

This is the initial implementation of rwbutler#26. I'll open a new PR with tests after some discussion + resolving rwbutler#27.

// Abort early if enough tasks have completed successfully
self?.cancelConnectivityCheck(pendingTasks: tasks, successfulChecks: successfulChecks,
totalChecks: totalChecks)
let completionHandlerForUrl: (URL) -> ((Data?, URLResponse?, Error?) -> Void) = { url in
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To include the URL in response validation, the signature here was updated to require passing the URL, so that it could be captured and included when moving on to response validation

@@ -0,0 +1,60 @@
//
// ConnectivityResponseValidation.swift
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the filename in the new PR

matchesRegularExpression
}

public class ConnectivityResponseStringTestValidator: ConnectivityResponseValidator {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is the old validator renamed and given a public API

@@ -300,15 +305,31 @@ private extension Connectivity {
}

/// Determines whether or not the connectivity check was successful.
private func connectivityCheckSucceeded(data: Data?) -> Bool {
guard let data = data, let responseString = String(data: data, encoding: .utf8) else {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved into the validator

@benasher44
Copy link
Owner Author

Closing this to reopen against main repo

@benasher44 benasher44 closed this Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants