MCPcopy Index your code
hub / github.com/cli/cli / TestNewCmdCreate

Function TestNewCmdCreate

pkg/cmd/repo/create/create_test.go:24–187  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestNewCmdCreate(t *testing.T) {
25 tests := []struct {
26 name string
27 tty bool
28 cli string
29 wantsErr bool
30 errMsg string
31 wantsOpts CreateOptions
32 }{
33 {
34 name: "no args tty",
35 tty: true,
36 cli: "",
37 wantsOpts: CreateOptions{Interactive: true},
38 },
39 {
40 name: "no args no-tty",
41 tty: false,
42 cli: "",
43 wantsErr: true,
44 errMsg: "at least one argument required in non-interactive mode",
45 },
46 {
47 name: "new repo from remote",
48 cli: "NEWREPO --public --clone",
49 wantsOpts: CreateOptions{
50 Name: "NEWREPO",
51 Public: true,
52 Clone: true},
53 },
54 {
55 name: "no visibility",
56 tty: true,
57 cli: "NEWREPO",
58 wantsErr: true,
59 errMsg: "`--public`, `--private`, or `--internal` required when not running interactively",
60 },
61 {
62 name: "multiple visibility",
63 tty: true,
64 cli: "NEWREPO --public --private",
65 wantsErr: true,
66 errMsg: "expected exactly one of `--public`, `--private`, or `--internal`",
67 },
68 {
69 name: "new remote from local",
70 cli: "--source=/path/to/repo --private",
71 wantsOpts: CreateOptions{
72 Private: true,
73 Source: "/path/to/repo"},
74 },
75 {
76 name: "new remote from local with remote",
77 cli: "--source=/path/to/repo --public --remote upstream",
78 wantsOpts: CreateOptions{
79 Public: true,
80 Source: "/path/to/repo",
81 Remote: "upstream",

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCreateFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected