include test case with failing metadata store
Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
parent
39a76fdd90
commit
7f477afa5d
2 changed files with 22 additions and 1 deletions
|
|
@ -301,4 +301,14 @@ func TestRunDownload(t *testing.T) {
|
|||
customOpts.APIClient = nil
|
||||
require.Error(t, runDownload(&customOpts))
|
||||
})
|
||||
|
||||
t.Run("fail to write attestations to metadata file", func(t *testing.T) {
|
||||
opts := baseOpts
|
||||
opts.Store = &MockStore{
|
||||
OnCreateMetadataFile: OnCreateMetadataFileFailure,
|
||||
}
|
||||
|
||||
err := runDownload(&opts)
|
||||
require.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
)
|
||||
|
||||
type MetadataStore interface {
|
||||
createJSONLinesFilePath(artifact string) string
|
||||
createMetadataFile(artifactDigest string, attestationsResp []*api.Attestation) (string, error)
|
||||
}
|
||||
|
||||
|
|
@ -57,3 +56,15 @@ func (s *LiveStore) createMetadataFile(artifactDigest string, attestationsResp [
|
|||
|
||||
return metadataFilePath, nil
|
||||
}
|
||||
|
||||
type MockStore struct {
|
||||
OnCreateMetadataFile func(artifactDigest string, attestationsResp []*api.Attestation) (string, error)
|
||||
}
|
||||
|
||||
func (s *MockStore) createMetadataFile(artifact string, attestationsResp []*api.Attestation) (string, error) {
|
||||
return s.OnCreateMetadataFile(artifact, attestationsResp)
|
||||
}
|
||||
|
||||
func OnCreateMetadataFileFailure(artifactDigest string, attestationsResp []*api.Attestation) (string, error) {
|
||||
return "", fmt.Errorf("failed to create trusted metadata file")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue