Skip to content

Conversation

@octoaide
Copy link
Contributor

@octoaide octoaide bot commented Dec 30, 2025

This PR adds comprehensive tests for the Settings configuration parsing and socket-address deserialization to satisfy issue #264.

What I changed

  • Added 17 new unit tests covering Settings::from_str, Settings::from_file, and deserialize_socket_addr behavior.
  • Added tempfile as a dev-dependency in Cargo.toml to create temporary TOML files for file-based tests.
  • Updated Cargo.lock accordingly.
  • Extended src/settings.rs with test cases (positive tests for TOML parsing and default injection; negative tests asserting user-friendly, stable error messages for invalid addresses and invalid file paths).

Tests added (high level)

  • Positive/behavioral: parsing representative TOML strings, injecting defaults when fields are omitted, IPv4/IPv6 address parsing, and reading configs from temporary files.
  • Negative/error messages: invalid IPv6 without brackets, missing port, non-numeric or out-of-range ports, empty/whitespace addresses, hostname without port, invalid TOML syntax, and non-existent config file path errors.

Notes on test design

  • Tests assert on stable substrings of error messages (using contains()) to keep assertions resilient to small formatting changes while still catching regressions in message content.
  • Temporary files are created with a .toml extension to ensure the config loader detects the format correctly.

Files changed

  • Cargo.toml (dev-dependency: tempfile)
  • Cargo.lock
  • src/settings.rs (tests)

Why this is needed
These tests ensure Settings parsing and socket-address deserialization behave correctly across expected inputs and failure modes, and they guard future changes by asserting stable, user-friendly error messages.

Closes #264

Related issue: #264

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 10.96%. Comparing base (4e1dd53) to head (856506c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #271      +/-   ##
==========================================
+ Coverage   10.19%   10.96%   +0.77%     
==========================================
  Files           8        7       -1     
  Lines         628      529      -99     
==========================================
- Hits           64       58       -6     
+ Misses        564      471      -93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@octoaide
Copy link
Contributor Author

octoaide bot commented Jan 14, 2026

Hi @kimhanbeom — friendly reminder about PR #271: "Add Settings::from_file/from_str and socket-address tests (#264)". This PR was approved by pott-cho on 2025-12-30, all CI checks are passing, and the branch is mergeable and not a draft. It adds tests, a dev-dependency (tempfile), and updates Cargo.lock; it also closes #264.

It's been over two weeks since approval and the PR is still mergeable with no pending change requests. Could you please merge this when convenient, or let me know if there's a reason to hold (release timing or other policy)? If you'd like, I can rebase or make any tiny follow-ups first — just tell me how you'd prefer to proceed. Thanks!

Cargo.toml Outdated
unwrap_used = "warn"

[dev-dependencies]
tempfile = "3.24.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pott-cho If a crate is not dependent on a specific version, we should specify only the major version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the test code, I noticed that from_file returns a ConfigError, while from_str (the FromStr implementation) returns anyhow::Error. While this isn't a bug, I believe it's a point where we need to achieve consistency. Could you please create an improvement issue to address this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue has been created: #277

@pott-cho pott-cho force-pushed the octoaide/issue-264-2025-12-30T03-28-36 branch from a6f8020 to 856506c Compare January 16, 2026 04:57
@kimhanbeom kimhanbeom merged commit 9f1fb86 into main Jan 21, 2026
10 checks passed
@kimhanbeom kimhanbeom deleted the octoaide/issue-264-2025-12-30T03-28-36 branch January 21, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configuration parser & socket-address deserialization tests (Settings::from_file/from_str)

4 participants