Dashboard › cli › Distillation
d63cca34-2c3f-4025-9393-787d14fb68d4["lore_tm_v1_meDCUJ9pWfRduiM40Sfd-VLoyn6DwPlC8sypYWYiVCU","lore_tm_v1_zQ9OhdKWnkDfTONhl-I3umoe3UkTUz4Y7ajeYrAf9dg","lore_tm_v1_J7sKV17pDKADdNLLDS6hjqNgxyzvQPk_GoOpFOHMYJE","lore_tm_v1_P3ZmIgQ44kbnFDHMS7nA6Repi7Azd-MuldHDbkE56m0","lore_tm_v1_U7uC8jRf3KhzmbZXjwmBqqfAWuX8l-ZmQ1LdpUV0gZI","lore_tm_v1_WHNe58UqR4dt3thQasylwJCST6gUD07embq02SSnzUo","lore_tm_v1_zGYkrwenVg3pD5BuCgn8uFvgXcsll7CfNTPZskZsLDY"]
π΄ (20:42) packages/cli/test/lib/upgrade.test.ts contains 2,118 lines of upgrade-module tests and mocks node:child_process with vi.mock() plus a mutable hoisted spawnImpl.fn; fakeProcess(exitCode, stdoutData) emits stdout chunks and then close on a microtask, while fakeErrorProcess(message) emits error.
π΄ (20:42) packages/cli/test/lib/upgrade.test.ts dynamically imports ../../src/lib/upgrade.js after the child-process mock and tests exports detectInstallationMethod, detectPackageManagerFromPath, downloadBinaryToTemp, executeUpgrade, fetchLatestFromGitHub, fetchLatestFromNpm, fetchLatestNightlyVersion, fetchLatestVersion, getCurlInstallPaths, parseInstallationMethod, startCleanupOldBinary, and versionExists.
π΄ (20:42) parseInstallationMethod() tests accept curl, brew, npm, pnpm, bun, and yarn; parsing is case-insensitive (NPM β npm, Curl β curl, YARN β yarn), while pip, apt, and the empty string throw exact Invalid method: ... messages.
π΄ (20:42) fetchLatestFromGitHub() tests cover tags with and without a v prefix, HTTP 404 yielding UpgradeError message Failed to fetch from GitHub: 404, network TypeError("fetch failed") yielding Failed to connect to GitHub: fetch failed, and missing tag_name yielding No version found in GitHub release.
π΄ (20:42) fetchLatestFromNpm() tests expect registry JSON { version: "1.2.3" } to return "1.2.3"; HTTP 500 maps to UpgradeError message Failed to fetch from npm: 500, network TypeError("fetch failed") maps to Failed to connect to npm registry: fetch failed, and absent version maps to No version found in npm registry.
π΄ (20:42) UpgradeError tests verify default reason/message pairs: unknown_method β Could not detect installation method. Use --method to specify., network_error β Failed to fetch version information., execution_failed β Upgrade command failed., version_not_found β The specified version was not found., and unsupported_operation β This operation is not supported for this installation method.
π΄ (20:42) fetchLatestVersion() tests route yarn and unknown installation methods to npm, route brew to GitHub releases, and default an omitted channel to stable GitHub releases.
π΄ (20:42) fetchLatestVersion(method, "nightly") tests use the GHCR nightly manifest annotation rather than version.json, returning "0.0.0-dev.1740393600" for both curl and npm; nightly is treated as a curl-only distribution regardless of the detected package-manager method.
π΄ (20:42) versionExists() tests route stable curl and brew versions to GitHub and stable npm, pnpm, bun, and yarn versions to npm; HTTP 200 means true, HTTP 404 means false, and network failures become UpgradeError messages referring to GitHub or the npm registry as applicable.
π΄ (20:42) versionExists() tests route nightly versions such as 0.14.0-dev.1772661724 to GHCR regardless of installation method; a found nightly-${version} manifest returns true, HTTP 404 returns false, and network failures or GHCR HTTP 500 responses throw UpgradeError.
π΄ (20:42) executeUpgrade("unknown", "1.0.0") is tested to throw UpgradeError with reason "unknown_method" and a message containing Could not detect installation method.
π΄ (20:42) Installation-detection tests assert stored install metadata takes precedence over a node_modules pathβfor example stored method "yarn" remains "yarn"βbut a Homebrew executable path such as /opt/homebrew/Cellar/sentry/1.2.3/bin/sentry takes priority and yields "brew".
π΄ (20:42) getBinaryDownloadUrl("1.0.0") tests require a URL beginning https://github.com/getsentry/cli/releases/download/, containing /1.0.0/, sentry-, and architecture arm64 or x64; repository release tags intentionally omit a v prefix.
π΄ (20:42) getCurlInstallPaths() tests require installPath, tempPath, oldPath, and lockPath, with exact derivations ${installPath}.download, ${installPath}.old, and ${installPath}.lock; installPath ends in sentry.exe on Windows and sentry otherwise.
π΄ (20:42) The stored-path branch of getCurlInstallPaths() trusts stored install metadata only when the stored executableβs directory still exists, avoiding locking or installing into a dead location.
π΄ (20:42) Curl-upgrade tests redirect installation into a temporary directory by storing { method: "curl", path: upgradeInstallPath, version: "0.0.0" }, and clean up the install, .download, .old, and .lock paths after each test.
π΄ (20:42) executeUpgrade("curl", "1.0.0") is tested to download and gzip-decompress ELF bytes [0x7f, 0x45, 0x4c, 0x46] into tempBinaryPath, returning both tempBinaryPath and lockPath.
π΄ (20:42) Curl binary download tests require fallback from the .gz asset to the raw binary after either .gz HTTP 404 or a .gz network exception; both scenarios make exactly 2 fetch attempts and preserve the raw binary bytes.
π΄ (20:42) When both compressed and raw binary URLs fail, curl upgrade tests expect HTTP 404 to produce UpgradeError message Failed to download binary: HTTP 404, while repeated network failures produce a message containing Failed to connect to GitHub.
π΄ (20:42) Curl upgrade failure tests verify the upgrade lock file is released even when both binary download attempts fail with HTTP 500.
π΄ (20:42) packages/cli/test/lib/ghcr.test.ts contains 558 lines of GHCR/OCI helper tests; all HTTP calls are mocked through globalThis.fetch.
π΄ (20:42) The GHCR test fixture makeManifest() defines OCI schema version 2, media type application/vnd.oci.image.manifest.v1+json, config digest sha256:config, and two binary layers: sha256:abc123 / 1,000 bytes / sentry-linux-x64.gz, and sha256:def456 / 1,200 bytes / sentry-darwin-arm64.gz; annotations include version 0.0.0-dev.1740000000 and source https://github.com/getsentry/cli.
π΄ (20:42) getAnonymousToken() tests require a request containing https://ghcr.io/token?scope=repository:${GHCR_REPO}:pull; a successful { token: "test-token-abc" } response returns the token, HTTP 401 produces GHCR token exchange failed: HTTP 401, network failure produces Failed to connect to GHCR: fetch failed, and a missing token field produces GHCR token exchange returned no token.
π΄ (20:42) fetchNightlyManifest("my-token") tests request /v2/${GHCR_REPO}/manifests/${GHCR_TAG} with Authorization: Bearer my-token and Accept: application/vnd.oci.image.manifest.v1+json; HTTP 404 produces Failed to fetch manifest for tag "nightly": HTTP 404, and network failure produces Failed to fetch manifest for tag "nightly": fetch failed.
π΄ (20:42) getNightlyVersion(manifest) extracts "0.0.0-dev.1740000000" from manifest annotations and throws UpgradeError with Nightly manifest has no version annotation when the annotation is missing; an absent annotations object also throws UpgradeError.
π΄ (20:42) findLayerByFilename() tests map sentry-linux-x64.gz to digest sha256:abc123 and sentry-darwin-arm64.gz to sha256:def456; missing sentry-freebsd-x64.gz produces No nightly build found for sentry-freebsd-x64.gz, and layers lacking annotations also cause UpgradeError.
π΄ (20:42) downloadNightlyBlob() tests accept a direct HTTP 200 response and manually follow HTTP 307 and 302 redirects; the bearer Authorization header must not be forwarded to redirected blob-storage hosts such as Azure.
π΄ (20:42) downloadNightlyBlob() error tests require: redirect without Location β GHCR blob redirect (307) had no Location header; redirected storage HTTP 403 β Blob storage download failed: HTTP 403; unexpected initial HTTP 500 β Unexpected GHCR blob response: HTTP 500; initial network failure β Failed to connect to GHCR: fetch failed; redirected-download network failure β Failed to download from blob storage: fetch failed.
π΄ (20:42) Generic fetchManifest("token", tag) tests use paths such as /v2/${GHCR_REPO}/manifests/patch-0.13.0; HTTP 404 produces Failed to fetch manifest for tag "patch-0.13.0": HTTP 404, and a network failure for "some-tag" produces Failed to fetch manifest for tag "some-tag": fetch failed.
π΄ (20:42) listTags() tests return all tags without a prefix and filter client-side with prefixes such as "patch-"; a missing tags field or no prefix matches returns [], HTTP 500 produces Failed to list GHCR tags: HTTP 500, and network failure produces Failed to list GHCR tags: fetch failed.
π΄ (20:42) listTags() pagination uses a page size of 100: a first page containing exactly 100 tags triggers a second request, and a 100-tag page plus 2-tag page returns exactly 102 ordered tags from tag-000 through tag-101 in 2 calls.
π΄ (20:42) listTags("token", "patch-") is tested against 80 mixed tagsβ40 patch-* followed by 40 nightly-*βand returns exactly the 40 matching patch tags.
π΄ (20:42) downloadLayerBlob("token", "sha256:abc123") tests request /v2/${GHCR_REPO}/blobs/sha256:abc123, follow a 307 redirect, and return the downloaded ArrayBuffer; network download failure throws UpgradeError.
π΄ (20:43) Install-script tests are located at packages/cli/test/lib/install-script.test.ts; they define installScript = join(repoRoot, "install") and use a top-level describe("install script", ...).
π΄ (20:43) packages/cli/test/lib/binary.test.ts contains 678 lines testing shared binary helpers including acquireLock, compareVersions, determineInstallDir, fetchWithUpgradeError, getBinaryDownloadUrl, getBinaryFilename, getBinaryPaths, getPlatformBinaryName, installBinary, isDowngrade, isMusl, releaseLock, and replaceBinarySync.
π΄ (20:43) getBinaryFilename() tests return "sentry" on non-Windows systems, while getBinaryDownloadUrl("2.0.0") is required to end in .exe only on Windows.
π΄ (20:43) getBinaryPaths("/usr/local/bin/sentry") tests exact derived values: installPath="/usr/local/bin/sentry", tempPath="/usr/local/bin/sentry.download", oldPath="/usr/local/bin/sentry.old", and lockPath="/usr/local/bin/sentry.lock".
π΄ (20:43) determineInstallDir() tests give SENTRY_INSTALL_DIR precedence when set and test preference for ~/.local/bin when that directory exists and is present in PATH.