feat: 支持跨平台前端镜像部署
This commit is contained in:
41
scripts/tests/deployFrontend.test.mjs
Normal file
41
scripts/tests/deployFrontend.test.mjs
Normal file
@@ -0,0 +1,41 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { parseArguments, parsePrePushLines, resolveImageTag } from '../deploy-frontend.mjs'
|
||||
|
||||
test('pre-push input resolves the exact commit being pushed', () => {
|
||||
const refs = parsePrePushLines(
|
||||
'refs/heads/iteration/august 94764b0e0a950fb841fd6c1e88578af34461f24c refs/heads/iteration/august 0000000000000000000000000000000000000000\n'
|
||||
)
|
||||
|
||||
assert.deepEqual(refs, [
|
||||
{
|
||||
localRef: 'refs/heads/iteration/august',
|
||||
localSha: '94764b0e0a950fb841fd6c1e88578af34461f24c',
|
||||
remoteRef: 'refs/heads/iteration/august',
|
||||
remoteSha: '0000000000000000000000000000000000000000'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
test('deleting a remote branch does not resolve a zero commit', () => {
|
||||
const refs = parsePrePushLines(
|
||||
'refs/heads/iteration/august 0000000000000000000000000000000000000000 refs/heads/iteration/august 94764b0e0a950fb841fd6c1e88578af34461f24c\n'
|
||||
)
|
||||
|
||||
assert.equal(refs[0].localSha, '0000000000000000000000000000000000000000')
|
||||
})
|
||||
|
||||
test('manual branch mode accepts a branch and rejects unknown options', () => {
|
||||
assert.deepEqual(parseArguments(['--branch', 'iteration/august']), {
|
||||
mode: 'branch',
|
||||
branch: 'iteration/august'
|
||||
})
|
||||
assert.throws(() => parseArguments(['--unknown']), /未知参数/)
|
||||
})
|
||||
|
||||
test('image tag is the commit SHA rather than a mutable branch tag', () => {
|
||||
assert.equal(
|
||||
resolveImageTag('94764b0e0a950fb841fd6c1e88578af34461f24c'),
|
||||
'94764b0e0a950fb841fd6c1e88578af34461f24c'
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user