MCPcopy
hub / github.com/cli/cli / TestCreateCmdFlagError

Function TestCreateCmdFlagError

pkg/cmd/codespace/create_test.go:19–57  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestCreateCmdFlagError(t *testing.T) {
20 tests := []struct {
21 name string
22 args string
23 wantsErr error
24 }{
25 {
26 name: "return error when using web flag with display-name, idle-timeout, or retention-period flags",
27 args: "--web --display-name foo --idle-timeout 30m",
28 wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
29 },
30 {
31 name: "return error when using web flag with one of display-name, idle-timeout or retention-period flags",
32 args: "--web --idle-timeout 30m",
33 wantsErr: fmt.Errorf("using --web with --display-name, --idle-timeout, or --retention-period is not supported"),
34 },
35 }
36
37 for _, tt := range tests {
38 t.Run(tt.name, func(t *testing.T) {
39 ios, _, _, _ := iostreams.Test()
40 a := &App{
41 io: ios,
42 }
43 cmd := newCreateCmd(a)
44
45 args, _ := shlex.Split(tt.args)
46 cmd.SetArgs(args)
47 cmd.SetIn(&bytes.Buffer{})
48 cmd.SetOut(&bytes.Buffer{})
49 cmd.SetErr(&bytes.Buffer{})
50
51 _, err := cmd.ExecuteC()
52
53 assert.Error(t, err)
54 assert.EqualError(t, err, tt.wantsErr.Error())
55 })
56 }
57}
58
59func TestApp_Create(t *testing.T) {
60 type fields struct {

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
newCreateCmdFunction · 0.85
ErrorfMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected