Remove Alamofire dependency from WordPressKit
It was "needed" for tests.
To test:
Regression Notes
-
Potential unintended areas of impact
-
What I did to test those areas of impact (or what existing automated tests I relied on)
-
What automated tests I added (or what prevented me from doing so)
PR submission checklist:
- [ ] I have completed the Regression Notes.
- [ ] I have considered adding unit tests for my changes.
- [ ] I have considered adding accessibility improvements for my changes.
- [ ] I have considered if this change warrants user-facing release notes and have added them to
RELEASE-NOTES.txtif necessary.
Testing checklist:
- [ ] WordPress.com sites and self-hosted Jetpack sites.
- [ ] Portrait and landscape orientations.
- [ ] Light and dark modes.
- [ ] Fonts: Larger, smaller and bold text.
- [ ] High contrast.
- [ ] VoiceOver.
- [ ] Languages with large words or with letters/accents not frequently used in English.
- [ ] Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
- [ ] iPhone and iPad.
- [ ] Multi-tasking: Split view and Slide over. (iPad)
📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr23386-ce10657 | |
| Version | 25.1 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | ce106575371f4e2703f282ea590df8dd09aed3cf | |
| App Center Build | WPiOS - One-Offs #10264 |
📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr23386-ce10657 | |
| Version | 25.1 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | ce106575371f4e2703f282ea590df8dd09aed3cf | |
| App Center Build | jetpack-installable-builds #9311 |
I honestly didn't read the tests because the use of Alamofire didn't seem to make sense.
but we should replace it with static test data that can be validated against
Done. Right, this way it'll catch if there any regressions.
Sorry to be annoying – can we use multi-line Swift strings for this so developers can read it right in the code?
Can you drop a comment on the lines you are referring to please?
There are inline base64 binary:
let expected = Data(base64Encoded: "LS10ZXN0Ym91bmRhcnkNCkNvbnRlbnQtRGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0ia2V5LTEiDQoNCmENCi0tdGVzdGJvdW5kYXJ5DQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImtleS0yIg0KDQpiDQotLXRlc3Rib3VuZGFyeS0tDQo=")!
Yeah, all the binary data is just a string like:
--wpkit.boundary.9d4adfc909a08bfa
Content-Disposition: form-data; name="world"
hello
--wpkit.boundary.9d4adfc909a08bfa--
We could probably just use that in the test for easier comparison?
We could probably just use that in the test for easier comparison?
It actually is, isn't it? There are just boundaries and .utf8 "blobs".
I tried it, but there is an issue with newlines. It encodes them as \r\n aka Windows encoding. Swift uses just \n if you have a multiline string.
--testboundary\r\nContent-Disposition: form-data; name=\"key-1\"\r\n\r\na\r\n--testboundary\r\nContent-Disposition: form-data; name=\"key-2\"\r\n\r\nb\r\n--testboundary--\r\n
So this won't be the same:
let expected = """
--testboundary
Content-Disposition: form-data; name="key-1"
a
--testboundary
Content-Disposition: form-data; name="key-2"
b
--testboundary--
""".data(using: .utf8)
But this will work:
let expected = "--testboundary\r\nContent-Disposition: form-data; name=\"key-1\"\r\n\r\na\r\n--testboundary\r\nContent-Disposition: form-data; name=\"key-2\"\r\n\r\nb\r\n--testboundary--\r\n".data(using: .utf8)
I'm changing it to that.
| 1 Warning | |
|---|---|
| :warning: | Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages in Xcode. |
Generated by :no_entry_sign: Danger