move mock client to test file
Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
parent
338f9cf78c
commit
ff1e8e46de
2 changed files with 13 additions and 12 deletions
|
|
@ -59,15 +59,3 @@ 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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,25 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/cli/cli/v2/pkg/cmd/attestation/api"
|
||||
"github.com/cli/cli/v2/pkg/cmd/attestation/artifact"
|
||||
"github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
func TestCreateJSONLinesFilePath(t *testing.T) {
|
||||
tempDir := t.TempDir()
|
||||
artifact, err := artifact.NewDigestedArtifact(oci.MockClient{}, "../test/data/sigstore-js-2.1.0.tgz", "sha512")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue