Merge pull request #8996 from cli/wm/improve-verify-error-messages

Improve errors when loading bundle locally fails
This commit is contained in:
William Martin 2024-04-26 17:48:37 +02:00 committed by GitHub
commit fc2aec380d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -13,7 +13,7 @@ import (
"github.com/sigstore/sigstore-go/pkg/bundle"
)
var ErrLocalAttestations = errors.New("failed to load local attestations")
var ErrUnrecognisedBundleExtension = errors.New("bundle file extension not supported, must be json or jsonl")
type FetchAttestationsConfig struct {
APIClient api.Client
@ -52,7 +52,7 @@ func GetLocalAttestations(path string) ([]*api.Attestation, error) {
}
return attestations, nil
}
return nil, ErrLocalAttestations
return nil, ErrUnrecognisedBundleExtension
}
func loadBundleFromJSONFile(path string) ([]*api.Attestation, error) {

View file

@ -48,7 +48,7 @@ func TestGetLocalAttestations(t *testing.T) {
path := "../test/data/sigstore-js-2.1.0-bundles.tgz"
attestations, err := GetLocalAttestations(path)
require.ErrorIs(t, err, ErrLocalAttestations)
require.ErrorIs(t, err, ErrUnrecognisedBundleExtension)
require.Nil(t, attestations)
})
}