Skip to content

test: comprehensive test coverage improvements (pure functions, SDK validation, command tests)#156

Draft
NianJiuZst wants to merge 17 commits into
MiniMax-AI:mainfrom
NianJiuZst:test/complete-core-coverage
Draft

test: comprehensive test coverage improvements (pure functions, SDK validation, command tests)#156
NianJiuZst wants to merge 17 commits into
MiniMax-AI:mainfrom
NianJiuZst:test/complete-core-coverage

Conversation

@NianJiuZst
Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive test coverage across four categories: pure utilities, SDK validation logic, thin command tests, and polling logic.

277 → 285 tests (+70 new, some existing tests enhanced)

Changes by category

Pure function unit tests (5 commits)

Commit Module Tests Coverage
maskToken utils/token.ts 5 short/long/empty/edge cases
CLIError/SDKError errors/base.ts 7 constructors, toJSON(), hint
isInteractive/isCI utils/env.ts 10 TTY detection, CI env vars
parseConfigFile config/schema.ts 17 api_key, region, output, timeout, proxy, OAuth, default models, unknown keys

SDK validateParams tests (5 commits)

All SDK validation rules now tested — previously 0% coverage:

Module Tests Coverage
SpeechSDK 2 text required (missing + empty)
ImageSDK 6 width/height paired, range, multiple-of-8, valid passes
VideoSDK 6 prompt, SEF/S2V mode constraints, Fast model, auto-selection
MusicSDK 8 instrumental+lyrics, lyrics_optimizer conflicts, missing fields, model/format validation, stream+url conflict
TextSDK 2 empty messages, defaults applied

Command test improvements (4 commits)

Command Before After Added
image generate 2 tests 9 tests width/height validation, out constraint, dry-run body
file upload 2 tests 4 tests file existence, dry-run with purpose
search query 2 tests 4 tests mock server: results display, empty results
quota show 2 tests 2 tests improved structure

Polling logic (1 commit)

Module Tests Coverage
polling/poll.ts 4 complete, failed with message, timeout, immediate success

Test results

285 tests / 0 fail / typecheck: clean

Design notes

  • SDK validation tests call methods without mock servers — validation happens before any network call, so missing/invalid params throw immediately
  • quota show mock server test was not possible because quotaEndpoint() rewrites the hostname to api.* subdomain, which breaks localhost mock server routing
  • 14 "Unhandled error between tests" warnings are pre-existing — present on origin/main before any of these changes

Files changed

File Status Tests
test/utils/token.test.ts New 5
test/errors/base.test.ts New 7
test/utils/env.test.ts New 10
test/config/schema.test.ts New 17
test/polling/poll.test.ts New 4
test/sdk/text.test.ts Modified +2
test/sdk/image.test.ts Modified +6
test/sdk/video.test.ts Modified +6
test/sdk/music.test.ts Modified +8
test/sdk/speech.test.ts Modified +2
test/commands/image/generate.test.ts Modified +7
test/commands/file/upload.test.ts Modified +2
test/commands/search/query.test.ts Modified +2
test/commands/quota/show.test.ts Modified improved

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.

1 participant