Skip to content

Commit

Permalink
Expand error test suite for ghasum verify
Browse files Browse the repository at this point in the history
Add two error scenario tests for the `ghasum verify` command. The aim
of this is to improve the program when things don't go as expected.

The first test corresponds to a scenario where there is a syntax error
in the ghasum sumfile. In particular, this tests that there is a failure
and that the error makes sense.

The second test corresponds to a scenario where there is a syntax error
in one of the workflows. In particular, this tests that there is a
failure and that the error makes sense.

Additionally, this aligns the test names with the error test suite for
`ghasum init` and `ghasum verify`. It also aligns the test data within
the test suite.
  • Loading branch information
ericcornelissen committed Mar 14, 2024
1 parent 55c6bbd commit 782d465
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions testdata/verify/error.txtar
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# Repo that doesn't use GitHub Actions
# Repo without GitHub Actions
! exec ghasum verify no-actions/
! stdout 'Ok'
stderr 'an unexpected error occurred'
stderr 'ghasum has not yet been initialized'

# Uninitialized repo that uses GitHub Actions
# Uninitialized repo with GitHub Actions
! exec ghasum verify uninitialized/
! stdout 'Ok'
stderr 'an unexpected error occurred'
stderr 'ghasum has not yet been initialized'

# Invalid sumfile
! exec ghasum verify invalid-sumfile/
! stdout 'Ok'
stderr 'an unexpected error occurred'
stderr 'could not decode the checksum file'

# Invalid workflow
! exec ghasum verify invalid-workflow/
! stdout 'Ok'
stderr 'an unexpected error occurred'
stderr 'could not parse workflow'
stderr '.github/workflows/workflow.yml'

# Directory not found
! exec ghasum verify directory-not-found/
! stdout 'Ok'
Expand All @@ -25,7 +38,7 @@ stderr 'no such file or directory'
-- initialized/.github/workflows/gha.sum --
version 1

actions/checkout@main PKruFKnotZi8RQ196H3R7c5bgw9+mfI7BN/h0A7XiV8=
actions/checkout@v4 Xl8z/l21IIpcBDsjpnq7jsBPk/RY26RwvDVL8FrajmE=
-- initialized/.github/workflows/workflow.yml --
name: Example workflow
on: [push]
Expand All @@ -36,7 +49,26 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@main
uses: actions/checkout@v4
-- invalid-sumfile/.github/workflows/gha.sum --
version 1

this-action/is-missing@a-checksum
-- invalid-workflow/.github/workflows/gha.sum --
version 1

actions/checkout@v4 Xl8z/l21IIpcBDsjpnq7jsBPk/RY26RwvDVL8FrajmE=
-- invalid-workflow/.github/workflows/workflow.yml --
name: Faulty workflow
on: [push]

jobs:
example:
name: example
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
-- no-actions/.keep --
This file exists to create a repo that does not use Github Actions.
-- uninitialized/.github/workflows/workflow.yml --
Expand Down

0 comments on commit 782d465

Please sign in to comment.