MCPcopy Create free account
hub / github.com/cli/cli / TestNewCmdMarkTemplate

Function TestNewCmdMarkTemplate

pkg/cmd/project/mark-template/mark_template_test.go:14–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestNewCmdMarkTemplate(t *testing.T) {
15 tests := []struct {
16 name string
17 cli string
18 wants markTemplateOpts
19 wantsErr bool
20 wantsErrMsg string
21 wantsExporter bool
22 }{
23 {
24 name: "not-a-number",
25 cli: "x",
26 wantsErr: true,
27 wantsErrMsg: "invalid number: x",
28 },
29 {
30 name: "number",
31 cli: "123",
32 wants: markTemplateOpts{
33 number: 123,
34 },
35 },
36 {
37 name: "owner",
38 cli: "--owner monalisa",
39 wants: markTemplateOpts{
40 owner: "monalisa",
41 },
42 },
43 {
44 name: "undo",
45 cli: "--undo",
46 wants: markTemplateOpts{
47 undo: true,
48 },
49 },
50
51 {
52 name: "json",
53 cli: "--format json",
54 wantsExporter: true,
55 },
56 }
57
58 t.Setenv("GH_TOKEN", "auth-token")
59
60 for _, tt := range tests {
61 t.Run(tt.name, func(t *testing.T) {
62 ios, _, _, _ := iostreams.Test()
63 f := &cmdutil.Factory{
64 IOStreams: ios,
65 }
66
67 argv, err := shlex.Split(tt.cli)
68 assert.NoError(t, err)
69
70 var gotOpts markTemplateOpts
71 cmd := NewCmdMarkTemplate(f, func(config markTemplateConfig) error {

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewCmdMarkTemplateFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected