MCPcopy Create free account
hub / github.com/conforma/cli / TestInitializeCmd

Function TestInitializeCmd

cmd/sigstore/initialize_test.go:30–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestInitializeCmd(t *testing.T) {
31 cases := []struct {
32 name string
33 args []string
34 expectedRoot string
35 expectedMirror string
36 }{
37 {
38 name: "no args",
39 expectedMirror: "https://tuf-repo-cdn.sigstore.dev",
40 },
41 {
42 name: "with root",
43 args: []string{"--root", "/some/path/root.json"},
44 expectedRoot: "/some/path/root.json",
45 expectedMirror: "https://tuf-repo-cdn.sigstore.dev",
46 },
47 {
48 name: "with mirror",
49 args: []string{"--mirror", "https://tuf.local"},
50 expectedMirror: "https://tuf.local",
51 },
52 {
53 name: "with root and mirror",
54 args: []string{"--root", "/some/path/root.json", "--mirror", "https://tuf.local"},
55 expectedRoot: "/some/path/root.json",
56 expectedMirror: "https://tuf.local",
57 },
58 }
59
60 for _, tt := range cases {
61 t.Run(tt.name, func(t *testing.T) {
62 initF := func(ctx context.Context, root, mirror string) error {
63 require.Equal(t, tt.expectedRoot, root)
64 require.Equal(t, tt.expectedMirror, mirror)
65 return nil
66 }
67
68 sigInitCmd := sigstoreInitializeCmd(initF)
69
70 sigCmd := NewSigstoreCmd()
71 sigCmd.AddCommand(sigInitCmd)
72
73 rootCmd := root.NewRootCmd()
74 rootCmd.AddCommand(sigCmd)
75
76 rootCmd.SetContext(context.Background())
77 rootCmd.SetArgs(append([]string{"sigstore", "initialize"}, tt.args...))
78
79 err := rootCmd.Execute()
80 require.NoError(t, err)
81 })
82 }
83}

Callers

nothing calls this directly

Calls 4

NewRootCmdFunction · 0.92
sigstoreInitializeCmdFunction · 0.85
NewSigstoreCmdFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected