[PR #189] [MERGED] Add unit tests for pure methods #299

Closed
opened 2026-02-27 20:24:09 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/189
Author: @ramsayleung
Created: 2/27/2021
Status: Merged
Merged: 3/9/2021
Merged by: @marioortizmanero

Base: masterHead: ramsay_add_unit_tests


📝 Commits (10+)

  • fe55750 Add test for json_insert macro and generate_random_string function.
  • 89e142b add test for headers module.
  • cd1f9c5 add test_read_token_cache test, and move all tests in oauth2.rs to test_oauth2.rs
  • 2cd8564 Add tests for append_device_id function.
  • b59982e add test for endpoint_url and auth_headers function.
  • 8d202ff Fix cargo fmt error.
  • 3f4960e Fix clippy error.
  • 0afba9e add #[cfg(test)] attribute to fix unused import warning.
  • 7cd65ad update test_generate_random_string.
  • faf6543 add macro to create HashSet.

📊 Changes

17 files changed (+413 additions, -197 deletions)

View changed files

📝 .gitignore (+1 -0)
📝 CHANGELOG.md (+1 -0)
📝 examples/current_user_recently_played.rs (+5 -5)
📝 examples/oauth_tokens.rs (+21 -11)
📝 examples/ureq/device.rs (+5 -3)
📝 examples/ureq/me.rs (+5 -3)
📝 examples/ureq/search.rs (+5 -3)
📝 examples/ureq/seek_track.rs (+5 -3)
📝 examples/webapp/src/main.rs (+3 -2)
📝 examples/with_refresh_token.rs (+3 -5)
📝 src/client.rs (+22 -1)
📝 src/http/mod.rs (+66 -0)
📝 src/lib.rs (+37 -14)
src/macros.rs (+42 -0)
📝 src/oauth2.rs (+2 -137)
tests/test_oauth2.rs (+170 -0)
📝 tests/test_with_oauth.rs (+20 -10)

📄 Description

Description

Add unit tests for pure methods like get_uri and get_type methods without external dependencies

Motivation and Context

Add more unit tests for rspotify to make it solid and easy to maintain and refactor

Dependencies

None

Type of change

Add unit tests

How Has This Been Tested?

Check if all added tests pass


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ramsayleung/rspotify/pull/189 **Author:** [@ramsayleung](https://github.com/ramsayleung) **Created:** 2/27/2021 **Status:** ✅ Merged **Merged:** 3/9/2021 **Merged by:** [@marioortizmanero](https://github.com/marioortizmanero) **Base:** `master` ← **Head:** `ramsay_add_unit_tests` --- ### 📝 Commits (10+) - [`fe55750`](https://github.com/ramsayleung/rspotify/commit/fe55750beb5390ab734c7105904f2d4d8ed6abb4) Add test for json_insert macro and generate_random_string function. - [`89e142b`](https://github.com/ramsayleung/rspotify/commit/89e142bbf0a5274b42ac6c7ba6e01f03fdacfed0) add test for headers module. - [`cd1f9c5`](https://github.com/ramsayleung/rspotify/commit/cd1f9c5d6ee056a4385bd3e58ccea856aa2d3493) add test_read_token_cache test, and move all tests in oauth2.rs to test_oauth2.rs - [`2cd8564`](https://github.com/ramsayleung/rspotify/commit/2cd8564883d7bd9b739873c39f6b683e9b99746e) Add tests for append_device_id function. - [`b59982e`](https://github.com/ramsayleung/rspotify/commit/b59982e07e389dbc527ffdfce296e88c653715bd) add test for endpoint_url and auth_headers function. - [`8d202ff`](https://github.com/ramsayleung/rspotify/commit/8d202ff4f3c56156335b233e4d0afde7f498ac20) Fix cargo fmt error. - [`3f4960e`](https://github.com/ramsayleung/rspotify/commit/3f4960edc753d244d7e9a067e4ea7a043200d270) Fix clippy error. - [`0afba9e`](https://github.com/ramsayleung/rspotify/commit/0afba9efd1e122dc728b06e4143467417059b85a) add #[cfg(test)] attribute to fix unused import warning. - [`7cd65ad`](https://github.com/ramsayleung/rspotify/commit/7cd65ad5483d417897092f57f2533ce6a208b024) update test_generate_random_string. - [`faf6543`](https://github.com/ramsayleung/rspotify/commit/faf6543e989d92b4c1c88150ba8b5739cdb3cb41) add macro to create HashSet. ### 📊 Changes **17 files changed** (+413 additions, -197 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) 📝 `CHANGELOG.md` (+1 -0) 📝 `examples/current_user_recently_played.rs` (+5 -5) 📝 `examples/oauth_tokens.rs` (+21 -11) 📝 `examples/ureq/device.rs` (+5 -3) 📝 `examples/ureq/me.rs` (+5 -3) 📝 `examples/ureq/search.rs` (+5 -3) 📝 `examples/ureq/seek_track.rs` (+5 -3) 📝 `examples/webapp/src/main.rs` (+3 -2) 📝 `examples/with_refresh_token.rs` (+3 -5) 📝 `src/client.rs` (+22 -1) 📝 `src/http/mod.rs` (+66 -0) 📝 `src/lib.rs` (+37 -14) ➕ `src/macros.rs` (+42 -0) 📝 `src/oauth2.rs` (+2 -137) ➕ `tests/test_oauth2.rs` (+170 -0) 📝 `tests/test_with_oauth.rs` (+20 -10) </details> ### 📄 Description ## Description Add unit tests for pure methods like `get_uri` and `get_type` methods without external dependencies ## Motivation and Context Add more unit tests for `rspotify` to make it solid and easy to maintain and refactor ## Dependencies None ## Type of change Add unit tests ## How Has This Been Tested? Check if all added tests pass --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:24:09 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#299
No description provided.