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

Function TestCreateCmdFlagError

pkg/cmd/codespace/create_test.go:19–62  ·  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 name: "return error when --repo is not in owner/repo format",
37 args: "--repo foo",
38 wantsErr: fmt.Errorf(`invalid value for --repo: expected the "OWNER/REPO" format, got "foo"`),
39 },
40 }
41
42 for _, tt := range tests {
43 t.Run(tt.name, func(t *testing.T) {
44 ios, _, _, _ := iostreams.Test()
45 a := &App{
46 io: ios,
47 }
48 cmd := newCreateCmd(a)
49
50 args, _ := shlex.Split(tt.args)
51 cmd.SetArgs(args)
52 cmd.SetIn(&bytes.Buffer{})
53 cmd.SetOut(&bytes.Buffer{})
54 cmd.SetErr(&bytes.Buffer{})
55
56 _, err := cmd.ExecuteC()
57
58 assert.Error(t, err)
59 assert.EqualError(t, err, tt.wantsErr.Error())
60 })
61 }
62}
63
64func TestApp_Create(t *testing.T) {
65 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