Skip to content

test: split SSH key config parsing and key generation tests#380

Merged
minhtule merged 2 commits into
masterfrom
chore/mt/improve-ssh-key-unit-test
Jul 7, 2026
Merged

test: split SSH key config parsing and key generation tests#380
minhtule merged 2 commits into
masterfrom
chore/mt/improve-ssh-key-unit-test

Conversation

@minhtule

@minhtule minhtule commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Related Tickets & Documents

  • Issue: N/A

Changes

  • Split TestNewKeyConfigAndGenerate_ByKeyType into two tests:
    • TestNewKeyConfig: all 12 parsing cases, no key generation
    • TestKeyConfigGenerate: one case per Generate code path (ed25519, ECDSA 256/384/521, RSA 2048)

Notes

  • Every parsing case previously ran Generate, so the RSA cases dominated the test runtime (1.5-4s out of ~12s total, sample build)
  • RSA-4096 was generated twice: once via the rsa key type with default bits, once via ssh-rsa
  • The RSA branch in Generate does not vary by key size, so a single 2048-bit case covers it
  • Test runtime drops to ~0.2s (sample build) with no loss of branch coverage

Generating keys for every parsing case made the test take seconds due
to repeated RSA-4096 generation. Parsing cases now only call
newKeyConfig, and Generate is exercised once per code path with the
cheapest RSA size.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the SSH key configuration tests to reduce runtime by decoupling configuration parsing coverage from expensive key generation.

Changes:

  • Split the former combined parsing+generation test into a parsing-only table test (TestNewKeyConfig_ByKeyType) and a generation-focused test (TestKeyConfigGenerate).
  • Limit RSA key generation coverage to a single (cheapest allowed) size while keeping one test per ECDSA curve and ED25519 generation path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.20%. Comparing base (105f62b) to head (f576abb).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #380      +/-   ##
==========================================
+ Coverage   86.06%   86.20%   +0.14%     
==========================================
  Files          40       40              
  Lines        2828     2828              
==========================================
+ Hits         2434     2438       +4     
+ Misses        269      265       -4     
  Partials      125      125              
Flag Coverage Δ
integration 54.89% <ø> (ø)
unit 78.67% <ø> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@clement0010 clement0010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍🏻

@minhtule minhtule merged commit 04f8bdf into master Jul 7, 2026
13 checks passed
@minhtule minhtule deleted the chore/mt/improve-ssh-key-unit-test branch July 7, 2026 14:57
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.

3 participants