-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Added tests for Single+Response and refactored Shared Test Helpers #1229
Conversation
abec4a3
to
68ae475
Compare
SwiftLint found issuesWarnings
Generated by 🚫 Danger |
Changelog.md
Outdated
@@ -1,4 +1,5 @@ | |||
# Next | |||
- Added tests for Single+Response and refactored Shared Test Helpers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if adding tests needs a CHANGELOG entry but we usually list all API breaking changes first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind removing this, I just saw a line saying
"Moved tests to Moya.xcodeproj." so wasn't sure if you usually include this sort of stuff there.
Should I move it to the bottom of breaking or get rid of it completely ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think moving it to the bottom would be great. Right under where we mention adding Single<Response>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me ! 👍
99619b7
to
b50a2fe
Compare
Updated the Changelog and also did a "Build without Cache" for good luck 🍀 |
@freak4pc I just cleared the cache and triggered a rebuild. |
Thanks for the review! @SD10 |
By the way this "cache" issue is probably the fault of |
Tests/TestHelpers.swift
Outdated
#if os(OSX) | ||
import AppKit | ||
#else | ||
import Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@freak4pc I think we have to import UIKit to use CGFloat 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was never there AFAIK. I think we need to import Foundation regardless of OS here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also didn't know the tests run on Xcode 9 / iOS 11 :) Haven't tried this locally. Will do a quick test and push a fix for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/Users/distiller/Moya/Tests/TestHelpers.swift:174:50: use of undeclared type 'CGFloat'; did you mean to use 'CGFloat'?
-- This is such a weird CI error.
I learned yesterday that CGFloat is not declared in Foundation. It's part of UIKit 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, perfect error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SD10 GCFloat
is actually imported in CoreGraphics
, which in turn is not included in Foundation
, but is included in UIKit
. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BasThomas I came to that realization after awhile! I have to stop thinking in the extreme that everything not in UIKit is Foundation. I originally thought that Foundation imported CoreGraphics because they have an Int.init(CGFloat)
... Stopping to think -- it's actually more likely that CoreGraphics extends Foundation with this initializer... I'm such a noob 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.apple.com/documentation/swift/int/1455396-init
->
Framework
Core Graphics
Documentation is* awesome. 😬
* And with is, I mean can be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that sort of is implicated in the "CG" prefix :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way this is an even more interesting thing to know:
https://developer.apple.com/documentation/coregraphics/cgfloat/nativetype
Codecov Report
@@ Coverage Diff @@
## 9.0.0-dev #1229 +/- ##
=============================================
+ Coverage 76.4% 79.16% +2.75%
=============================================
Files 24 24
Lines 763 763
=============================================
+ Hits 583 604 +21
+ Misses 180 159 -21
Continue to review full report at Codecov.
|
Changelog.md
Outdated
@@ -3,6 +3,7 @@ | |||
- **Breaking Change** Flattened `UploadType` and `DownloadType` into `Task` cases. | |||
- Added Swift 4.0 support. | |||
- Added all the `filter`/`map` operators that were available for `Observable<Response>` to `Single<Response>` as well. | |||
- Added tests for Single+Response and refactored Shared Test Helpers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just:
Added tests for
Single<Response>
operators.
The refactor part might not be as important in my opinion.
Tests/Single+MoyaSpec.swift
Outdated
it("maps data representing an image to an image") { | ||
let image = Image.testPNGImage(named: "testImage") | ||
guard let data = image.asJPEGRepresentation(0.75) else { | ||
fail("Failed creating Data from Image") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that fatalError
might better here, as it is not a failed test, but rather an error in preparation (this one is in few more places as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually had fatalError there and changed it to fail "on the last minute". I actually think both are fine but i'll change :)
Tests/TestHelpers.swift
Outdated
return self.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)! | ||
} | ||
} | ||
#if os(OSX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to stick to more verbose conditional statements (as we had before):
#if os(iOS) || os(watchOS) || os(tvOS)
...
#elseif os(OSX)
...
#endif
return Image(contentsOfFile: path!)! | ||
} | ||
|
||
#if os(iOS) || os(watchOS) || os(tvOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we have here 😄
This contains it in ImageType and also cleared a Swiftlint warning.
7362f04
to
0b8c3c6
Compare
Changelog.md
Outdated
@@ -7,6 +7,7 @@ | |||
- Added Swift 4.0 support. | |||
- Added all the `filter`/`map` operators that were available for `Observable<Response>` to `Single<Response>` as well. | |||
- Added `AuthorizationType` to `AccessTokenAuthorizable` representing request headers of `.none`, `.basic`, and `.bearer`. | |||
- Added tests for Single<Response> operators. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minor one, but you forgot backticks around Single<Response>
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough ;)
0b8c3c6
to
96479a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for these, @freak4pc 🎉
This PR adds tests for Single+Response (for RxMoya), fixing issue #1227.
This PR also:
RxTestHelpers.swift
.TestHelpers.swift
.TestHelpers.swift
with someMARK
s and sectioning of helper methods / classes.