handle os.PathError in GetLocalAttestations
Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
parent
945e2b7eee
commit
bbefc5b24f
2 changed files with 10 additions and 2 deletions
|
|
@ -86,7 +86,7 @@ func loadBundleFromJSONFile(path string) ([]*api.Attestation, error) {
|
|||
func loadBundlesFromJSONLinesFile(path string) ([]*api.Attestation, error) {
|
||||
fileContent, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not read file: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
attestations := []*api.Attestation{}
|
||||
|
|
|
|||
|
|
@ -88,13 +88,21 @@ func TestGetLocalAttestations(t *testing.T) {
|
|||
require.Nil(t, attestations)
|
||||
})
|
||||
|
||||
t.Run("with non-existent bundle file", func(t *testing.T) {
|
||||
t.Run("with non-existent bundle file and JSON file", func(t *testing.T) {
|
||||
path := "../test/data/not-found-bundle.json"
|
||||
attestations, err := GetLocalAttestations(path)
|
||||
|
||||
require.ErrorContains(t, err, "bundle could not be loaded from JSON file")
|
||||
require.Nil(t, attestations)
|
||||
})
|
||||
|
||||
t.Run("with non-existent bundle file and JSON lines file", func(t *testing.T) {
|
||||
path := "../test/data/not-found-bundle.jsonl"
|
||||
attestations, err := GetLocalAttestations(path)
|
||||
|
||||
require.ErrorContains(t, err, "bundles could not be loaded from JSON lines file")
|
||||
require.Nil(t, attestations)
|
||||
})
|
||||
}
|
||||
|
||||
func TestFilterAttestations(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue