import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { test } from 'node:test'; import { formatOssutilCommand, readReleaseDryRun } from './release-oss.mjs'; test('dry run only accepts explicit truthy values', () => { assert.equal(readReleaseDryRun({}), false); assert.equal(readReleaseDryRun({ AGC_RELEASE_DRY_RUN: '1' }), true); assert.equal(readReleaseDryRun({ AGC_RELEASE_DRY_RUN: ' true ' }), true); assert.equal(readReleaseDryRun({ AGC_RELEASE_DRY_RUN: '0' }), false); assert.equal(readReleaseDryRun({ AGC_RELEASE_DRY_RUN: '' }), false); }); test('printed upload command keeps arguments and hides credentials', () => { const command = formatOssutilCommand({ binary: 'ossutil', args: [ 'cp', '--force', '陶泥儿 0.1.48.exe', 'oss://agc-dev/agc/dev-win/x.exe', ], endpoint: 'oss-rg-china-mainland.aliyuncs.com', credentials: true, }); assert.match(command, /^ossutil cp --force /u); assert.match(command, /"陶泥儿 0\.1\.48\.exe"/u); assert.match(command, /oss:\/\/agc-dev\/agc\/dev-win\/x\.exe/u); assert.match( command, /--access-key-id --access-key-secret /u, ); }); test('uploader gates every ossutil call behind the dry run switch', () => { const source = readFileSync( new URL('./release-upload.mjs', import.meta.url), 'utf8', ); assert.match(source, /const dryRun = readReleaseDryRun\(\);/u); assert.match(source, /if \(dryRun\) \{/u); assert.match(source, /dry-run:未写入任何 OSS 对象/u); });