add tests for json output
Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
parent
b5ffcf116d
commit
12c7de2559
2 changed files with 37 additions and 8 deletions
|
|
@ -42,10 +42,11 @@ func TestNewInspectCmd(t *testing.T) {
|
|||
}
|
||||
|
||||
testcases := []struct {
|
||||
name string
|
||||
cli string
|
||||
wants Options
|
||||
wantsErr bool
|
||||
name string
|
||||
cli string
|
||||
wants Options
|
||||
wantsErr bool
|
||||
wantsExporter bool
|
||||
}{
|
||||
{
|
||||
name: "Invalid digest-alg flag",
|
||||
|
|
@ -90,6 +91,17 @@ func TestNewInspectCmd(t *testing.T) {
|
|||
},
|
||||
wantsErr: true,
|
||||
},
|
||||
{
|
||||
name: "Prints output in JSON format",
|
||||
cli: fmt.Sprintf("%s --bundle %s --format json", artifactPath, bundlePath),
|
||||
wants: Options{
|
||||
ArtifactPath: artifactPath,
|
||||
BundlePath: bundlePath,
|
||||
DigestAlgorithm: "sha256",
|
||||
OCIClient: oci.MockClient{},
|
||||
},
|
||||
wantsExporter: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
|
|
@ -118,6 +130,7 @@ func TestNewInspectCmd(t *testing.T) {
|
|||
assert.Equal(t, tc.wants.DigestAlgorithm, opts.DigestAlgorithm)
|
||||
assert.NotNil(t, opts.OCIClient)
|
||||
assert.NotNil(t, opts.Logger)
|
||||
assert.Equal(t, tc.wantsExporter, opts.exporter != nil)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,11 @@ func TestNewVerifyCmd(t *testing.T) {
|
|||
}
|
||||
|
||||
testcases := []struct {
|
||||
name string
|
||||
cli string
|
||||
wants Options
|
||||
wantsErr bool
|
||||
name string
|
||||
cli string
|
||||
wants Options
|
||||
wantsErr bool
|
||||
wantsExporter bool
|
||||
}{
|
||||
{
|
||||
name: "Invalid digest-alg flag",
|
||||
|
|
@ -166,6 +167,20 @@ func TestNewVerifyCmd(t *testing.T) {
|
|||
},
|
||||
wantsErr: true,
|
||||
},
|
||||
{
|
||||
name: "Prints output in JSON format",
|
||||
cli: "../test/data/sigstore-js-2.1.0.tgz --bundle ../test/data/sigstore-js-2.1.0-bundle.json --owner sigstore --format json",
|
||||
wants: Options{
|
||||
ArtifactPath: test.NormalizeRelativePath("../test/data/sigstore-js-2.1.0.tgz"),
|
||||
BundlePath: test.NormalizeRelativePath("../test/data/sigstore-js-2.1.0-bundle.json"),
|
||||
DigestAlgorithm: "sha256",
|
||||
Limit: 30,
|
||||
OIDCIssuer: GitHubOIDCIssuer,
|
||||
Owner: "sigstore",
|
||||
SANRegex: "^https://github.com/sigstore/",
|
||||
},
|
||||
wantsExporter: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
|
|
@ -204,6 +219,7 @@ func TestNewVerifyCmd(t *testing.T) {
|
|||
assert.NotNil(t, opts.APIClient)
|
||||
assert.NotNil(t, opts.Logger)
|
||||
assert.NotNil(t, opts.OCIClient)
|
||||
assert.Equal(t, tc.wantsExporter, opts.exporter != nil)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue