From 782d4651f0ed58f5323032c4e26bb613f3c6f480 Mon Sep 17 00:00:00 2001 From: Eric Cornelissen Date: Thu, 14 Mar 2024 22:28:04 +0100 Subject: [PATCH] Expand error test suite for `ghasum verify` 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. --- testdata/verify/error.txtar | 40 +++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/testdata/verify/error.txtar b/testdata/verify/error.txtar index f943456..2e05768 100644 --- a/testdata/verify/error.txtar +++ b/testdata/verify/error.txtar @@ -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' @@ -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] @@ -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 --