Skip to content

test(sdk/node): add unit tests for the Node SDK#15

Merged
arham766 merged 1 commit into
tiliondev:mainfrom
abtonmoy:test/node-sdk-unit-tests
Jul 4, 2026
Merged

test(sdk/node): add unit tests for the Node SDK#15
arham766 merged 1 commit into
tiliondev:mainfrom
abtonmoy:test/node-sdk-unit-tests

Conversation

@abtonmoy

@abtonmoy abtonmoy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

The Python SDK is covered by sdk/python/tests/test_sdk.py, but the Node SDK had no tests — even though sdk/node/index.js holds the release-critical logic that decides which bundle a user downloads and whether it is trusted. A regression there ships a broken installer silently.

This PR adds a unit suite for that logic, mirroring the Python side, and gates it in CI.

Changes

  • sdk/node/test/sdk.test.js — new suite using the built-in node:test runner (no new dependencies). No network or browser is required; fetch is mocked.
  • sdk/node/index.js — export ASSETS, personaArgs, sha256, and expectedSha so the pure functions are reachable from the test. Additive only; no runtime behaviour changes.
  • .github/workflows/ci.yml — run node --test sdk/node/test/ in the existing node-sdk job (renamed node sdk syntaxnode sdk tests).

Coverage

Function What's checked
resolvePlatform() The four supported platform/arch pairs; unsupported combos return null
personaArgs() Known keys → correct --uxr-* flags; unknown keys fall back to a --uxr- prefix (never a bare/branded flag); null/undefined/{}[]
expectedSha() Parses SHA256SUMS; handles the sha256sum *asset binary marker; returns null for a missing asset, a non-ok response, or a network error
sha256() Matches Node's crypto for a known buffer
ASSETS Consistent with resolvePlatform(); every launcher lives under tilion-fortress/

Verification

$ node --test sdk/node/test/
# tests 13
# pass 13
# fail 0

node --check on the CLI and library still passes, and the patch-integrity linter is unaffected.

Closes #10

The Python SDK is covered by sdk/python/tests/test_sdk.py, but the Node
SDK had no tests despite index.js holding the release-critical logic that
decides which bundle a user downloads and whether it is trusted. A
regression there ships a broken installer silently.

Add sdk/node/test/sdk.test.js using the built-in node:test runner (no new
dependencies), mirroring the Python suite:

- resolvePlatform(): the four supported platform/arch pairs plus a range
  of unsupported combos returning null.
- personaArgs(): known keys map to the correct --uxr-* flags, unknown
  keys still fall back to a --uxr- prefix (never a bare or branded flag),
  and null/undefined/{} yield [].
- expectedSha(): parses SHA256SUMS, handles the sha256sum "*asset" binary
  marker, returns null for a missing asset, a non-ok response, or a
  network error (fetch is mocked, so no network is required).
- sha256(): matches Node's crypto for a known buffer.
- ASSETS: stays consistent with resolvePlatform() and every launcher
  lives under tilion-fortress/.

To make the pure functions reachable from the test, export ASSETS,
personaArgs, sha256, and expectedSha from index.js. This is an additive
change with no effect on runtime behaviour.

Wire node --test sdk/node/test/ into the node-sdk CI job.

Closes tiliondev#10
@arham766 arham766 merged commit fb28462 into tiliondev:main Jul 4, 2026
5 checks 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.

test(sdk/node): add unit tests for the Node SDK (mirror the Python suite)

2 participants