Repository navigation
Expand file tree
/
Copy pathrelease.test.mjs
More file actions
2 lines (2 loc) · 1.6 KB
/
Copy pathrelease.test.mjs
File metadata and controls
2 lines (2 loc) · 1.6 KB
1
2
import {test} from 'node:test';import assert from 'node:assert/strict';import {mkdtemp,writeFile,readFile,rm} from 'node:fs/promises';import {tmpdir} from 'node:os';import {join} from 'node:path';import {createHash} from 'node:crypto';import {writeReleaseManifest} from './tools/release-manifest.mjs';
test('release metadata identifies the runtime ZIP, not the source archive, and binds its checksum',async()=>{const dir=await mkdtemp(join(tmpdir(),'deskthing-release-'));try{const manifest={id:'fixture',label:'Fixture',version:'1.2.3',requires:[],tags:['utilityOnly'],requiredVersions:{server:'>=0.11.17',client:'>=0.11.2 <0.11.3'}};const bytes=Buffer.from('runtime archive bytes');const manifestPath=join(dir,'manifest.json');await writeFile(manifestPath,JSON.stringify(manifest));await writeFile(join(dir,'fixture-v1.2.3.zip'),bytes);await writeFile(join(dir,'Fixture-source-v1.2.3.zip'),'source should never be selected');const result=await writeReleaseManifest({directory:dir,manifestPath,repo:'Fixture',now:1234});assert.equal(result.meta_type,'app');assert.equal(result.meta_version,'0.11.8');assert.deepEqual(result.appManifest,manifest);assert.equal(result.updateUrl,'https://github.com/HyperXcess/Fixture/releases/download/v1.2.3/fixture-v1.2.3.zip');assert.equal(result.repository,'https://api.github.com/repos/HyperXcess/Fixture');assert.equal(result.size,bytes.length);assert.equal(result.hashAlgorithm,'sha512');assert.equal(result.hash,createHash('sha512').update(bytes).digest('hex'));assert.deepEqual(JSON.parse(await readFile(join(dir,'latest.json'),'utf8')),result);}finally{await rm(dir,{recursive:true,force:true});}});