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

[Tests] Try different urls before failing the test. #6237

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tests/monotouch-test/Foundation/NSDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,14 @@ public void Https ()
Assert.Ignore ("NSData.FromUrl doesn't seem to work in watchOS");
}
#endif
NSError error;
using (var url = new NSUrl ("https://www.microsoft.com/robots.txt"))
using (var x = NSData.FromUrl (url)) {
Assert.That ((x != null) && (x.Length > 0));
using (var x = NSData.FromUrl (url, NSDataReadingOptions.Uncached, out error)) {
if (error != null) {
Assert.Inconclusive ($"Could not access url error is '{error.Description}'");
} else {
Assert.That ((x != null) && (x.Length > 0));
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved
}
Copy link
Contributor

Choose a reason for hiding this comment

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

the test was to detect an error...
with that change I don't think you can trigger the 2nd assert (unless an empty file was present)
so basically the test can't fail (so it's not worth much)

Copy link
Member Author

Choose a reason for hiding this comment

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

@spouliot we can check the domain of the error and decide what to do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well.. thx Cocoa, we would get the not so useful "NSCocoaErrorDomain Code=256", which means an unknown error happened.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, a reachability (to host) error would be fine to ignore, but other errors would not be

Copy link
Member Author

Choose a reason for hiding this comment

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

I have used several company urls, lets hope trying several will work, else we can do an increasing timeout retry.

}
}

Expand Down