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

Function TestNewCmdReadFile

pkg/cmd/repo/read-file/read_file_test.go:70–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestNewCmdReadFile(t *testing.T) {
71 tests := []struct {
72 name string
73 args string
74 wantOpts ReadFileOptions
75 wantErr string
76 }{
77 {
78 name: "path only",
79 args: "README.md",
80 wantOpts: ReadFileOptions{
81 Path: "README.md",
82 },
83 },
84 {
85 name: "with ref",
86 args: "README.md --ref v1.2.3",
87 wantOpts: ReadFileOptions{
88 Path: "README.md",
89 Ref: "v1.2.3",
90 },
91 },
92 {
93 name: "with output and clobber",
94 args: "README.md --output out.md --clobber",
95 wantOpts: ReadFileOptions{
96 Path: "README.md",
97 Output: "out.md",
98 Clobber: true,
99 },
100 },
101 {
102 name: "with allow-escape-sequences",
103 args: "README.md --allow-escape-sequences",
104 wantOpts: ReadFileOptions{
105 Path: "README.md",
106 AllowEscapeSequences: true,
107 },
108 },
109 {
110 name: "no arguments",
111 args: "",
112 wantErr: "accepts 1 arg(s), received 0",
113 },
114 {
115 name: "too many arguments",
116 args: "a.md b.md",
117 wantErr: "accepts 1 arg(s), received 2",
118 },
119 {
120 name: "json and output are mutually exclusive",
121 args: "README.md --json name --output out.md",
122 wantErr: "specify only one of `--json` or `--output`",
123 },
124 }
125
126 for _, tt := range tests {
127 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

TestFunction · 0.92
NewCmdReadFileFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected