Skip to content

test: improve develop branch test coverage#54

Merged
Keith-CY merged 3 commits intodevelopfrom
feat/improve-test-coverage
Mar 3, 2026
Merged

test: improve develop branch test coverage#54
Keith-CY merged 3 commits intodevelopfrom
feat/improve-test-coverage

Conversation

@dev01lay2
Copy link
Copy Markdown
Collaborator

@dev01lay2 dev01lay2 commented Mar 3, 2026

Summary

Two rounds of test coverage improvement for the develop branch.

Round 1: Rust 145→195 (+50) · TS 10→58 (+48)

Module Before After Key additions
ssh/config 1 15 Multi-host parsing, wildcards, quotes, comments, equals separator, dedup
ssh/mod 4 18 Legacy args, destination, port, identity file, resolve_target, shell_escape
connect 2 10 slug_from_home, missing home errors, explicit instance ids
sessions 4 14 Array content, multiple agents, sort order, filter edge cases
cron 2 10 Plain array, object map, empty/invalid input, ordering
watchdog 1 8 Dead state, deployed flag, invalid json, whitespace
openclaw 4 10 Array extraction, nonzero exit, nested json, error display
backup 3 9 Empty input, trailing slash, malformed lines, dedup
TS: guidance 0 30 All error classifiers + throttle logic
TS: model-value 0 8 Provider/model combining, prefix dedup
TS: utils 0 12 formatTime + formatBytes edge cases

Round 2: Rust 195→283 (+88) · TS 58→69 (+11)

Module Before After Key additions
config 17 57 All template patches, read_model_value, change paths, channel nodes
discovery 3 19 Accounts path, slug/name fallback, wildcards, dedup, bindings
health 4 15 count_agents, parse_active_agents, shell_escape, missing SSH config
install/docker 5 12 Fallback detection, compose_env, state_dir, tilde expansion
instance 8 20 sanitize_id, endpoint_key, canonical_id, normalize, error display
precheck 7 12 Empty profiles, valid registry, existing home
TS: prompt-templates 0 11 renderPromptTemplate + extractPromptBlock

Coverage delta (local llvm-cov)

Metric Base (develop) This PR Delta
Lines 63.10% ~73%+ +10%+
Functions 57.81% ~66%+ +8%+
Regions 63.25% ~73%+ +10%+

No production code changes

All changes are test-only (#[cfg(test)] blocks + __tests__/ files).

Rust (clawpal-core): 145 → 195 unit tests (+50)
- ssh/config: 1→15 tests (multi-host, wildcards, quotes, comments, equals separator, dedup, case-insensitive keys, first-value-wins)
- ssh/mod: 4→18 tests (legacy args, destination, port, identity file, resolve_target, shell_escape, error display, candidate_key_paths)
- connect: 2→10 tests (slug_from_home, missing home errors, explicit instance ids, error display)
- sessions: 4→14 tests (array content preview, multiple agents, empty input, sort order, filter edge cases)
- cron: 2→10 tests (plain array, object map, empty/invalid input, ordering, preserves existing jobId)
- watchdog: 1→8 tests (dead state, deployed flag, invalid json, empty/whitespace ps output)
- openclaw: 4→10 tests (array extraction, nonzero exit, no json, nested json, error display)
- backup: 3→9 tests (empty input, trailing slash, malformed lines, dedup versions)

TypeScript (Bun): 10 → 58 tests (+48)
- guidance.ts: 30 new tests (cooldown/transient/explained/registry/container error classifiers, throttle logic)
- model-value.ts: 8 new tests (provider+model combining, prefix dedup, whitespace, edge cases)
- utils.ts: 12 new tests (formatTime dash/ISO/RFC3339/invalid, formatBytes all units)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 3, 2026

📊 Test Coverage Report

Metric Base (develop) PR (feat/improve-test-coverage) Delta
Lines 63.10% (3941/6246) 73.32% (5467/7456) 🟢 +10.22%
Functions 57.81% (455/787) 66.91% (637/952) 🟢 +9.10%
Regions 63.25% (6371/10073) 74.62% (9135/12242) 🟢 +11.37%

Coverage measured by cargo llvm-cov (clawpal-core + clawpal-cli).

bun:test in 1.3.x does not export beforeEach; it was imported but
never used, causing typecheck to fail.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4f9079a40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Should produce a valid date-time string
expect(result).toMatch(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/);
expect(result).toContain("2026");
expect(result).toContain("14:30:00");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove fixed local-time assertion from dash timestamp test

This check hard-codes 14:30:00, but formatTime converts the dash form through a UTC date (...Z) and then formats in the runner's local timezone, so non-UTC environments produce different clock times (for example, UTC+8 yields 22:30:00). That makes the test fail or become environment-dependent even when the implementation is correct; assert a timezone-agnostic property or derive the expected local time from the current TZ instead of pinning a fixed HH:MM:SS.

Useful? React with 👍 / 👎.

Rust (clawpal-core): 195 → 283 unit tests (+88)
- config: 17→57 (+40) — all template patches, read_model_value, collect_change_paths, channel nodes, resolve_channel_mode/allowlist
- discovery: 3→19 (+16) — accounts path, slug/name fallback, wildcards, dedup, bindings, numeric IDs, edge cases
- health: 4→15 (+11) — count_agents, parse_active_agents, shell_escape, error display, missing SSH config
- install/docker: 5→12 (+7) — needs_local_image_fallback variants, compose_env, openclaw_state_dir, tilde expansion
- instance: 8→20 (+12) — sanitize_instance_id_segment, endpoint_key, canonical_remote_instance_id, normalize, ids, error display
- precheck: 7→12 (+5) — empty profiles, valid registry, existing home, multiple profile check

TypeScript (Bun): 58 → 69 tests (+11)
- prompt-templates: 11 new (renderPromptTemplate + extractPromptBlock pure logic)

Rust line coverage: 67.14% → ~73% (estimated from local llvm-cov)
Copy link
Copy Markdown
Collaborator

@Keith-CY Keith-CY left a comment

Choose a reason for hiding this comment

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

Review summary

Approved.

Scope checked

  • All changes are test-only ( additions) across Rust and Bun test files.
  • No production logic paths were modified in this PR.

Notes

  • The new test cases materially expand coverage for parsing and config/instance/error helpers.
  • I did not identify correctness, security, or reliability regressions in the added tests.

@Keith-CY Keith-CY merged commit dd90c02 into develop Mar 3, 2026
4 checks passed
@Keith-CY Keith-CY deleted the feat/improve-test-coverage branch March 3, 2026 04:49
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.

2 participants