mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Additional 3.7.0 tests
This commit is contained in:
parent
1d5e1bc6d3
commit
65691af8c1
@ -211,6 +211,7 @@ describe('git', () => {
|
|||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
folder: 'assets',
|
folder: 'assets',
|
||||||
|
folderPath: 'assets',
|
||||||
branch: 'branch',
|
branch: 'branch',
|
||||||
gitHubToken: '123',
|
gitHubToken: '123',
|
||||||
lfs: true,
|
lfs: true,
|
||||||
@ -230,26 +231,33 @@ describe('git', () => {
|
|||||||
expect(response).toBe(Status.SUCCESS)
|
expect(response).toBe(Status.SUCCESS)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
it('should appropriately move along if git stash errors', async () => {
|
||||||
|
;(execute as jest.Mock).mockImplementation(cmd => {
|
||||||
|
if (cmd === 'git stash apply') {
|
||||||
|
// Mocks the case where git stash apply errors.
|
||||||
|
throw new Error()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
folder: 'assets',
|
folder: 'assets',
|
||||||
|
folderPath: 'assets',
|
||||||
branch: 'branch',
|
branch: 'branch',
|
||||||
gitHubToken: '123',
|
gitHubToken: '123',
|
||||||
|
lfs: true,
|
||||||
|
preserve: true,
|
||||||
|
isTest: true,
|
||||||
pusher: {
|
pusher: {
|
||||||
name: 'asd',
|
name: 'asd',
|
||||||
email: 'as@cat'
|
email: 'as@cat'
|
||||||
},
|
}
|
||||||
clean: true
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const response = await deploy(action)
|
const response = await deploy(action)
|
||||||
|
|
||||||
fs.createWriteStream('assets/.nojekyll')
|
|
||||||
fs.createWriteStream('assets/CNAME')
|
|
||||||
|
|
||||||
// Includes the call to generateBranch
|
// Includes the call to generateBranch
|
||||||
expect(execute).toBeCalledTimes(12)
|
expect(execute).toBeCalledTimes(14)
|
||||||
expect(rmRF).toBeCalledTimes(1)
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
expect(response).toBe(Status.SUCCESS)
|
expect(response).toBe(Status.SUCCESS)
|
||||||
})
|
})
|
||||||
@ -257,14 +265,16 @@ describe('git', () => {
|
|||||||
it('should execute commands with single commit toggled', async () => {
|
it('should execute commands with single commit toggled', async () => {
|
||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
folder: 'assets',
|
folder: 'other',
|
||||||
|
folderPath: 'other',
|
||||||
branch: 'branch',
|
branch: 'branch',
|
||||||
gitHubToken: '123',
|
gitHubToken: '123',
|
||||||
singleCommit: true,
|
singleCommit: true,
|
||||||
pusher: {
|
pusher: {
|
||||||
name: 'asd',
|
name: 'asd',
|
||||||
email: 'as@cat'
|
email: 'as@cat'
|
||||||
}
|
},
|
||||||
|
clean: true
|
||||||
})
|
})
|
||||||
|
|
||||||
await deploy(action)
|
await deploy(action)
|
||||||
@ -274,11 +284,37 @@ describe('git', () => {
|
|||||||
expect(rmRF).toBeCalledTimes(1)
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
||||||
|
Object.assign(action, {
|
||||||
|
silent: false,
|
||||||
|
folder: 'assets',
|
||||||
|
folderPath: 'assets',
|
||||||
|
branch: 'branch',
|
||||||
|
gitHubToken: '123',
|
||||||
|
pusher: {
|
||||||
|
name: 'asd',
|
||||||
|
email: 'as@cat'
|
||||||
|
},
|
||||||
|
clean: true
|
||||||
|
})
|
||||||
|
|
||||||
|
fs.createWriteStream('assets/.nojekyll')
|
||||||
|
fs.createWriteStream('assets/CNAME')
|
||||||
|
|
||||||
|
const response = await deploy(action)
|
||||||
|
|
||||||
|
// Includes the call to generateBranch
|
||||||
|
expect(execute).toBeCalledTimes(12)
|
||||||
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
|
expect(response).toBe(Status.SUCCESS)
|
||||||
|
})
|
||||||
|
|
||||||
it('should execute commands with clean options, ommits sha commit message', async () => {
|
it('should execute commands with clean options, ommits sha commit message', async () => {
|
||||||
process.env.GITHUB_SHA = ''
|
process.env.GITHUB_SHA = ''
|
||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
folder: 'assets',
|
folder: 'other',
|
||||||
|
folderPath: 'other',
|
||||||
branch: 'branch',
|
branch: 'branch',
|
||||||
gitHubToken: '123',
|
gitHubToken: '123',
|
||||||
pusher: {
|
pusher: {
|
||||||
@ -286,7 +322,8 @@ describe('git', () => {
|
|||||||
email: 'as@cat'
|
email: 'as@cat'
|
||||||
},
|
},
|
||||||
clean: true,
|
clean: true,
|
||||||
cleanExclude: '["cat", "montezuma"]'
|
cleanExclude: '["cat", "montezuma"]',
|
||||||
|
workspace: 'other'
|
||||||
})
|
})
|
||||||
|
|
||||||
await deploy(action)
|
await deploy(action)
|
||||||
@ -300,6 +337,7 @@ describe('git', () => {
|
|||||||
Object.assign(action, {
|
Object.assign(action, {
|
||||||
silent: false,
|
silent: false,
|
||||||
folder: 'assets',
|
folder: 'assets',
|
||||||
|
folderPath: 'assets',
|
||||||
branch: 'branch',
|
branch: 'branch',
|
||||||
gitHubToken: '123',
|
gitHubToken: '123',
|
||||||
pusher: {
|
pusher: {
|
||||||
|
@ -173,10 +173,6 @@ export async function deploy(action: ActionInterface): Promise<Status> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await execute(`git stash apply`, action.workspace, action.silent)
|
await execute(`git stash apply`, action.workspace, action.silent)
|
||||||
|
|
||||||
if (action.isTest) {
|
|
||||||
throw new Error()
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
info('Unable to apply from stash, continuing…')
|
info('Unable to apply from stash, continuing…')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user