cli/pkg/cmd/attestation/inspect/options_test.go
Meredith Lancaster 884fe225d1 add inspect cmd
Signed-off-by: Meredith Lancaster <malancas@github.com>
2024-03-04 13:55:05 -07:00

48 lines
1.2 KiB
Go

package inspect
import (
"testing"
"github.com/cli/cli/v2/pkg/cmd/attestation/test"
"github.com/stretchr/testify/assert"
)
func TestAreFlagsValid(t *testing.T) {
artifactPath := test.NormalizeRelativePath("../test/data/public-good/sigstore-js-2.1.0.tgz")
bundlePath := test.NormalizeRelativePath("../test/data/public-good/sigstore-js-2.1.0-bundle.json")
t.Run("missing BundlePath", func(t *testing.T) {
opts := Options{
ArtifactPath: artifactPath,
DigestAlgorithm: "sha512",
}
err := opts.AreFlagsValid()
assert.Error(t, err)
assert.ErrorContains(t, err, "bundle must be provided")
})
t.Run("missing DigestAlgorithm", func(t *testing.T) {
opts := Options{
ArtifactPath: artifactPath,
BundlePath: bundlePath,
}
err := opts.AreFlagsValid()
assert.Error(t, err)
assert.ErrorContains(t, err, "digest-alg cannot be empty")
})
t.Run("invalid DigestAlgorithm", func(t *testing.T) {
opts := Options{
ArtifactPath: artifactPath,
BundlePath: bundlePath,
DigestAlgorithm: "sha1",
}
err := opts.AreFlagsValid()
assert.Error(t, err)
assert.ErrorContains(t, err, "invalid digest algorithm 'sha1' provided in digest-alg")
})
}