diff --git a/pkg/cmd/attestation/verification/attestation.go b/pkg/cmd/attestation/verification/attestation.go index 6107ccf4e..d6e7d9e15 100644 --- a/pkg/cmd/attestation/verification/attestation.go +++ b/pkg/cmd/attestation/verification/attestation.go @@ -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{} diff --git a/pkg/cmd/attestation/verification/attestation_test.go b/pkg/cmd/attestation/verification/attestation_test.go index e321ffd87..68914afad 100644 --- a/pkg/cmd/attestation/verification/attestation_test.go +++ b/pkg/cmd/attestation/verification/attestation_test.go @@ -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) {