WeTransfer / Mocker

Mock Alamofire and URLSession requests without touching your code implementation
MIT License
1.1k stars 96 forks source link

Linux support #116

Closed vox-humana closed 2 years ago

vox-humana commented 2 years ago

These extra imports allow to use the library in tests on Linux. As an example I've enabled Linux tests in kean/Get library.

Also, removed unrelated warning that swift build showed:

Mocker.swift:79:21: warning: result of call to 'registerClass' is unused
        URLProtocol.registerClass(MockingURLProtocol.self)
                    ^            ~~~~~~~~~~~~~~~~~~~~~~~~~
BasThomas commented 2 years ago

I wonder if we can run a build on Linux to verify that this works as expected and does not break in the future?

wetransferplatform commented 2 years ago
Messages
:book: View more details on Bitrise
:book: MockerTests: Executed 25 tests (0 failed, 0 retried, 0 skipped) in 1.807 seconds

SwiftLint found issues

Severity File Reason
Warning Mocker.swift:96 Line should be 140 characters or less: currently 149 characters (line_length)
Error MockingURLProtocol.swift:41 Line should be 160 characters or less: currently 166 characters (line_length)
Error MockingURLProtocol.swift:44 Line should be 160 characters or less: currently 200 characters (line_length)
Warning MockingURLProtocol.swift:101 Line should be 140 characters or less: currently 147 characters (line_length)
Error MockingURLProtocol.swift:105 Line should be 160 characters or less: currently 221 characters (line_length)
Error Mock.swift:8 Line should be 160 characters or less: currently 177 characters (line_length)
Warning Mock.swift:76 Line should be 140 characters or less: currently 155 characters (line_length)
Error Mock.swift:108 Line should be 160 characters or less: currently 211 characters (line_length)
Error Mock.swift:111 Line should be 160 characters or less: currently 208 characters (line_length)
Error Mock.swift:120 Line should be 160 characters or less: currently 287 characters (line_length)
Warning Mock.swift:149 Line should be 140 characters or less: currently 142 characters (line_length)
Warning Mock.swift:156 Line should be 140 characters or less: currently 141 characters (line_length)
Error Mock.swift:163 Line should be 160 characters or less: currently 246 characters (line_length)
Error Mock.swift:164 Line should be 160 characters or less: currently 236 characters (line_length)
Warning Mock.swift:175 Line should be 140 characters or less: currently 150 characters (line_length)
Warning Mock.swift:176 Line should be 140 characters or less: currently 153 characters (line_length)
Warning Mock.swift:212 Line should be 140 characters or less: currently 159 characters (line_length)
Error Mock.swift:222 Line should be 160 characters or less: currently 168 characters (line_length)

Code Coverage Report

Name Coverage
Mocker.framework 86.42%

Generated by :no_entry_sign: Danger Swift against 9b2a6f7de644aeb73ae2114f102d5466874df0fa

kairadiagne commented 2 years ago

We should indicate in the README on which platforms the framework is available.

wetransferplatform commented 2 years ago

Congratulations! :tada: This was released as part of Release 2.5.6 :rocket:

Generated by GitBuddy

vox-humana commented 2 years ago

I wonder if we can run a build on Linux to verify that this works as expected and does not break in the future?

@BasThomas I am happy to add a simple Github action. Ideally it should also run tests via swift test, however, tests currently depend on UIKit, so swift test is failing not only on Linux but also on macOS. As far as I can see the only reason for importing UIKit is comparing images (UIImage) in tests. I think tests might just compare NSData instead. What do you think?

Also, not sure what's the current status of CI on the project. I see there is a Travis CI badge but seems like it is very outdated 🤔

BasThomas commented 2 years ago

As far as I can see the only reason for importing UIKit is comparing images (UIImage) in tests. I think tests might just compare NSData instead. What do you think?

Looks like it (and in the bridging header, but that's likely to be a CocoaPods artefact). We can either compare data, or use an NSImage on macOS.

Also, not sure what's the current status of CI on the project. I see there is a Travis CI badge but seems like it is very outdated 🤔

CI is run on Bitrise (using https://github.com/WeTransfer/WeTransfer-iOS-CI); I think that badge is indeed outdated 😂

Let us know if you'd be willing to tackle this; that'd be great!

vox-humana commented 2 years ago

It definitely took me more than I initially thought 😅 https://github.com/WeTransfer/Mocker/pull/118 @BasThomas let's continue discussion there.