MCPcopy
hub / github.com/cli/cli / TestRunInspect

Function TestRunInspect

pkg/cmd/attestation/inspect/inspect_test.go:26–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24var bundlePath = test.NormalizeRelativePath("../test/data/sigstore-js-2.1.0-bundle.json")
25
26func TestRunInspect(t *testing.T) {
27 opts := Options{
28 BundlePath: bundlePath,
29 Logger: io.NewTestHandler(),
30 OCIClient: oci.MockClient{},
31 SigstoreVerifier: verification.NewMockSigstoreVerifier(t),
32 }
33
34 t.Run("with valid bundle and default output", func(t *testing.T) {
35 testIO, _, out, _ := iostreams.Test()
36 opts.Logger = io.NewHandler(testIO)
37
38 require.Nil(t, runInspect(&opts))
39 outputStr := string(out.Bytes()[:])
40
41 assert.Regexp(t, "PredicateType:......... https://slsa.dev/provenance/v1", outputStr)
42 })
43
44 t.Run("with missing bundle path", func(t *testing.T) {
45 customOpts := opts
46 customOpts.BundlePath = test.NormalizeRelativePath("../test/data/non-existent-sigstoreBundle.json")
47 require.Error(t, runInspect(&customOpts))
48 })
49}
50
51func TestJSONOutput(t *testing.T) {
52 testIO, _, out, _ := iostreams.Test()

Callers

nothing calls this directly

Calls 8

NewTestHandlerFunction · 0.92
NewMockSigstoreVerifierFunction · 0.92
TestFunction · 0.92
NewHandlerFunction · 0.92
NormalizeRelativePathFunction · 0.92
runInspectFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected