MCPcopy
hub / github.com/cli/cli / TestNewCmdSync

Function TestNewCmdSync

pkg/cmd/repo/sync/sync_test.go:19–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestNewCmdSync(t *testing.T) {
20 tests := []struct {
21 name string
22 tty bool
23 input string
24 output SyncOptions
25 wantErr bool
26 errMsg string
27 }{
28 {
29 name: "no argument",
30 tty: true,
31 input: "",
32 output: SyncOptions{},
33 },
34 {
35 name: "destination repo",
36 tty: true,
37 input: "cli/cli",
38 output: SyncOptions{
39 DestArg: "cli/cli",
40 },
41 },
42 {
43 name: "source repo",
44 tty: true,
45 input: "--source cli/cli",
46 output: SyncOptions{
47 SrcArg: "cli/cli",
48 },
49 },
50 {
51 name: "branch",
52 tty: true,
53 input: "--branch trunk",
54 output: SyncOptions{
55 Branch: "trunk",
56 },
57 },
58 {
59 name: "force",
60 tty: true,
61 input: "--force",
62 output: SyncOptions{
63 Force: true,
64 },
65 },
66 }
67 for _, tt := range tests {
68 t.Run(tt.name, func(t *testing.T) {
69 ios, _, _, _ := iostreams.Test()
70 ios.SetStdinTTY(tt.tty)
71 ios.SetStdoutTTY(tt.tty)
72 f := &cmdutil.Factory{
73 IOStreams: ios,
74 }
75 argv, err := shlex.Split(tt.input)
76 assert.NoError(t, err)

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewCmdSyncFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected