WeTransfer / Mocker

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

Add option to create a custom data type #121

Closed alexanderwe closed 2 years ago

alexanderwe commented 2 years ago

Hey all,

at first thanks a lot for this great library! I saw that it is not possible to easily extend Mock.DataType with custom ones. Therefore I try to solve this issue with this PR. I changed the type from enum to struct to give consumers the ability to create new instances of DataType.

Furthermore I already created static variables on the DataType to not break any existing code with the types that were previously already in the library.

I needed this particular feature, because I also want to test my network responses if they return a specific kind of content type.

I would very appreciate if you could have a look into this :) Also happy for any feedback here !

alexanderwe commented 2 years ago

Thanks a lot, I got some minor (nit) changes that I wish to see changed, but other than that we're good! I'm looking into running CI.

Thanks a lot for taking a look that fast ! Updated the PR with your suggestions

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.714 seconds

SwiftLint found issues

Severity File Reason
Error Mock.swift:8 Line should be 160 characters or less: currently 177 characters (line_length)
Warning Mock.swift:49 Line should be 140 characters or less: currently 155 characters (line_length)
Error Mock.swift:81 Line should be 160 characters or less: currently 211 characters (line_length)
Error Mock.swift:84 Line should be 160 characters or less: currently 208 characters (line_length)
Error Mock.swift:93 Line should be 160 characters or less: currently 287 characters (line_length)
Warning Mock.swift:122 Line should be 140 characters or less: currently 142 characters (line_length)
Warning Mock.swift:129 Line should be 140 characters or less: currently 141 characters (line_length)
Error Mock.swift:136 Line should be 160 characters or less: currently 246 characters (line_length)
Error Mock.swift:137 Line should be 160 characters or less: currently 236 characters (line_length)
Warning Mock.swift:148 Line should be 140 characters or less: currently 150 characters (line_length)
Warning Mock.swift:149 Line should be 140 characters or less: currently 153 characters (line_length)
Warning Mock.swift:185 Line should be 140 characters or less: currently 159 characters (line_length)
Error Mock.swift:195 Line should be 160 characters or less: currently 168 characters (line_length)

Code Coverage Report

Name Coverage
Mocker.framework 87.93%

Generated by :no_entry_sign: Danger Swift against bde694018c2fad3a35400384ce68c3b64adb414d

wetransferplatform commented 2 years ago

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

Generated by GitBuddy

alexanderwe commented 2 years ago

@AvdLee Thanks a lot for approving and already releasing it. Really appreciate it 🙂