Skip to content

add resource command tests for every CLI action#8

Merged
alvseven merged 6 commits into
mainfrom
alves/add-resource-tests
May 15, 2026
Merged

add resource command tests for every CLI action#8
alvseven merged 6 commits into
mainfrom
alves/add-resource-tests

Conversation

@alvseven
Copy link
Copy Markdown
Member

No description provided.

alvseven added 2 commits May 15, 2026 17:07
Mocks fetch, captures the URL/method/body of each apiGet/apiPost/apiPut/
apiDelete call, and asserts the action functions construct them correctly.
Covers all 50+ command actions in src/commands/resources.ts — existing
receivers/bank_accounts/payouts/payins/quotes/webhook_endpoints/partner_fees/
api_keys/virtual_accounts/offramp_wallets/instances/available, plus the
new wallets/transfers/transfer_quotes/fees/tos/upload groups and the
fixed receivers limits paths.

Also pins one error-path behavior per shape: non-2xx responses route
through handleApiError, validation errors are surfaced from the body.
- CLAUDE.md: document the testing infrastructure (helpers, mock fetch
  pattern, exit-code convention) and add a 'step 3' in the sync workflow
  conventions telling the api-sync agent to add/update/remove tests
  alongside command changes. Also fix the stale 'bump CLI_VERSION in
  constants.ts' instruction left over from PR #6 — package.json is the
  source of truth now.
- api-sync.yml: mirror the same instruction in the inline prompt so
  Claude is told to update resources.test.ts before running 'bun run
  test'. Step renumbered (now 9 total).
- resources.test.ts: capture console.log output (instead of silently
  dropping it) so error tests can assert what was printed. Upgrade
  the two error tests to assert the specific exit code (2 for API
  errors, 1 for client-side) and the JSON error payload shape. Tighten
  the upload test to assert FormData and that 'file'/'bucket' parts
  are present, not just typeof === 'object'.
@alvseven alvseven force-pushed the alves/add-resource-tests branch from 9921c5e to db01098 Compare May 15, 2026 20:12
@alvseven alvseven changed the base branch from alves/backfill-cli-resources to main May 15, 2026 20:12
alvseven added 4 commits May 15, 2026 17:26
The action chooses a URL path from the --network option (evm by default,
or solana / stellar). Only the evm default was pinned; the other two
branches would have silently regressed. Adds one test per branch.

Also forces a head update on this PR so the CI workflow re-fires — the
`pull_request.branches: [main]` filter didn't match when the PR was
originally opened against alves/backfill-cli-resources, and GitHub does
not auto-rerun pull_request on base-branch changes.
- (2) drop the unused contentType: null branch in the fetch stub;
  responses are always JSON now.
- (4) tighten the small create bodies from toMatchObject to toEqual so
  field removals would actually fail the test (createBlockchainWallet,
  createPayinQuote, createWebhookEndpoint, createApiKey,
  createVirtualAccount). Also tighten the large bodies (createReceiver,
  createBankAccount, createPartnerFee) with their full expected shape
  including defaulted/null fields — this surfaced two real bodies I'd
  missed (createBankAccount's swift_ifsc_branch_code: null and
  createBlockchainWallet's name + external_id defaults).
- (5) move uploadFile fixtures off hardcoded /tmp; use a makeTempFile()
  helper that writes into os.tmpdir() and unlinks in afterEach.
- (6) normalize test names toward '<function> → <verb> <path>' or
  '<function> with --flag → <effect>' for the few that were prose.
Matches the convention used in api-client.test.ts and output.test.ts —
plain verb-phrase descriptions without function-arrow notation, no
'should' prefix. Combined with the describe blocks (Receivers, Bank
Accounts, …) the output reads as natural sentences:

  Receivers
    ✓ lists receivers
    ✓ fetches a receiver by id
    ✓ creates a receiver, splitting --name into first_name and last_name
    ✓ updates only the fields explicitly passed via flags
    ✓ deletes a receiver by id
    …

No semantic changes — every test still asserts the same URL/method/body
as before.
@alvseven alvseven merged commit 127dc0b into main May 15, 2026
1 check passed
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