Skip to content

Commit

Permalink
Merge pull request #903 from peter-evans/failure-mode-test
Browse files Browse the repository at this point in the history
test: add test for detached head failure mode
  • Loading branch information
peter-evans committed Aug 13, 2021
2 parents b90b9c1 + 00cb0ab commit 093c191
Show file tree
Hide file tree
Showing 3 changed files with 7,557 additions and 6 deletions.
22 changes: 22 additions & 0 deletions __test__/create-or-update-branch.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1740,4 +1740,26 @@ describe('create-or-update-branch tests', () => {
])
).toBeTruthy()
})

// This failure mode is a limitation of the action. Controlling your own commits cannot be used in detached HEAD state.
// https://github.com/peter-evans/create-pull-request/issues/902
it('tests failure to create with commits on the working base (during the workflow) in detached HEAD state (WBNR)', async () => {
// Checkout the HEAD commit SHA
const headSha = await git.revParse('HEAD')
await git.checkout(headSha)

// Create commits on the working base
const commits = await createCommits(git)
const commitMessage = uuidv4()
const result = await createOrUpdateBranch(
git,
commitMessage,
BASE,
BRANCH,
REMOTE_NAME,
false
)
// The action cannot successfully create the branch
expect(result.action).toEqual('none')
})
})
2 changes: 1 addition & 1 deletion __test__/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY __test__/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EOF

docker build -t $IMAGE .
docker build --no-cache -t $IMAGE .
rm Dockerfile
fi

Expand Down
Loading

0 comments on commit 093c191

Please sign in to comment.