42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { mkdtemp, writeFile } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import test from 'node:test'
|
|
|
|
import { resolveInternalReleaseVersion } from './internal-release-version.mjs'
|
|
|
|
test('reads the version from tauri.conf.json', async () => {
|
|
const root = await mkdtemp(join(tmpdir(), 'hololake-release-version-'))
|
|
await writeFile(join(root, 'tauri.conf.json'), JSON.stringify({ version: '1.2.3' }))
|
|
|
|
assert.equal(await resolveInternalReleaseVersion(join(root, 'tauri.conf.json')), '1.2.3')
|
|
})
|
|
|
|
test('accepts an explicit matching version', async () => {
|
|
const root = await mkdtemp(join(tmpdir(), 'hololake-release-version-'))
|
|
await writeFile(join(root, 'tauri.conf.json'), JSON.stringify({ version: '1.2.3' }))
|
|
|
|
assert.equal(await resolveInternalReleaseVersion(join(root, 'tauri.conf.json'), '1.2.3'), '1.2.3')
|
|
})
|
|
|
|
test('rejects a version that differs from the application configuration', async () => {
|
|
const root = await mkdtemp(join(tmpdir(), 'hololake-release-version-'))
|
|
await writeFile(join(root, 'tauri.conf.json'), JSON.stringify({ version: '1.2.3' }))
|
|
|
|
await assert.rejects(
|
|
resolveInternalReleaseVersion(join(root, 'tauri.conf.json'), '1.2.4'),
|
|
/does not match configured version 1\.2\.3/,
|
|
)
|
|
})
|
|
|
|
test('rejects malformed configured versions', async () => {
|
|
const root = await mkdtemp(join(tmpdir(), 'hololake-release-version-'))
|
|
await writeFile(join(root, 'tauri.conf.json'), JSON.stringify({ version: 'tomorrow' }))
|
|
|
|
await assert.rejects(
|
|
resolveInternalReleaseVersion(join(root, 'tauri.conf.json')),
|
|
/valid semantic version/,
|
|
)
|
|
})
|