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

Function TestNewCmdImport

pkg/cmd/alias/imports/import_test.go:24–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestNewCmdImport(t *testing.T) {
25 tests := []struct {
26 name string
27 cli string
28 tty bool
29 wants ImportOptions
30 wantsError string
31 }{
32 {
33 name: "no filename and stdin tty",
34 cli: "",
35 tty: true,
36 wants: ImportOptions{
37 Filename: "",
38 OverwriteExisting: false,
39 },
40 wantsError: "no filename passed and nothing on STDIN",
41 },
42 {
43 name: "no filename and stdin is not tty",
44 cli: "",
45 tty: false,
46 wants: ImportOptions{
47 Filename: "-",
48 OverwriteExisting: false,
49 },
50 },
51 {
52 name: "stdin arg",
53 cli: "-",
54 wants: ImportOptions{
55 Filename: "-",
56 OverwriteExisting: false,
57 },
58 },
59 {
60 name: "multiple filenames",
61 cli: "aliases1 aliases2",
62 wants: ImportOptions{
63 Filename: "aliases1 aliases2",
64 OverwriteExisting: false,
65 },
66 wantsError: "too many arguments",
67 },
68 {
69 name: "clobber flag",
70 cli: "aliases --clobber",
71 wants: ImportOptions{
72 Filename: "aliases",
73 OverwriteExisting: true,
74 },
75 },
76 }
77
78 for _, tt := range tests {
79 t.Run(tt.name, func(t *testing.T) {
80 ios, _, _, _ := iostreams.Test()
81 ios.SetStdinTTY(tt.tty)

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewCmdImportFunction · 0.85
SetStdinTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected