From 28fddffcf80e6d1a8ed1b0416da7fff9790259d2 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 31 Jul 2020 16:57:41 +0900 Subject: [PATCH] Add test for signoff --- __test__/create-or-update-branch.int.test.ts | 63 ++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/__test__/create-or-update-branch.int.test.ts b/__test__/create-or-update-branch.int.test.ts index d8db654..dfb01fd 100644 --- a/__test__/create-or-update-branch.int.test.ts +++ b/__test__/create-or-update-branch.int.test.ts @@ -757,6 +757,69 @@ describe('create-or-update-branch tests', () => { ).toBeTruthy() }) + it('tests create and update with signoff on commit', async () => { + // Create tracked and untracked file changes + const changes = await createChanges() + const commitMessage = uuidv4() + const result = await createOrUpdateBranch( + git, + commitMessage, + '', + BRANCH, + REMOTE_NAME, + true + ) + expect(result.action).toEqual('created') + expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked) + expect(await getFileContent(UNTRACKED_FILE)).toEqual(changes.untracked) + expect( + await gitLogMatches([commitMessage, INIT_COMMIT_MESSAGE]) + ).toBeTruthy() + // Check signoff in commit body + const commitBody = ( + await git.exec(['log', `-1`, '--format=%b']) + ).stdout.trim() + expect(commitBody).toEqual( + 'Signed-off-by: Committer Name ' + ) + + // Push pull request branch to remote + await git.push([ + '--force-with-lease', + REMOTE_NAME, + `HEAD:refs/heads/${BRANCH}` + ]) + + await afterTest(false) + await beforeTest() + + // Create tracked and untracked file changes + const _changes = await createChanges() + const _commitMessage = uuidv4() + const _result = await createOrUpdateBranch( + git, + _commitMessage, + '', + BRANCH, + REMOTE_NAME, + true + ) + expect(_result.action).toEqual('updated') + expect(_result.hasDiffWithBase).toBeTruthy() + expect(await getFileContent(TRACKED_FILE)).toEqual(_changes.tracked) + expect(await getFileContent(UNTRACKED_FILE)).toEqual(_changes.untracked) + expect( + await gitLogMatches([_commitMessage, INIT_COMMIT_MESSAGE]) + ).toBeTruthy() + // Check signoff in commit body + const _commitBody = ( + await git.exec(['log', `-1`, '--format=%b']) + ).stdout.trim() + expect(_commitBody).toEqual( + 'Signed-off-by: Committer Name ' + ) + }) + // Working Base is Not Base (WBNB) it('tests no changes resulting in no new branch being created (WBNB)', async () => {