MCPcopy Index your code
hub / github.com/smallstep/cli / TestReadInput

Function TestReadInput

utils/read_test.go:169–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestReadInput(t *testing.T) {
170 type args struct {
171 prompt string
172 }
173 tests := []struct {
174 name string
175 args args
176 before func() func()
177 want []byte
178 wantErr bool
179 }{
180 {"ok", args{"Write input"}, func() func() {
181 content := []byte("my file content")
182 mockStdin, cleanup := newFile(t, content)
183 reset := setStdin(mockStdin)
184 return func() {
185 defer cleanup()
186 reset()
187 }
188 }, []byte("my file content"), false},
189 }
190 for _, tt := range tests {
191 t.Run(tt.name, func(t *testing.T) {
192 cleanup := tt.before()
193 defer cleanup()
194 got, err := ReadInput(tt.args.prompt)
195 if (err != nil) != tt.wantErr {
196 t.Errorf("ReadInput() error = %v, wantErr %v", err, tt.wantErr)
197 return
198 }
199 if !reflect.DeepEqual(got, tt.want) {
200 t.Errorf("ReadInput() = %v, want %v", got, tt.want)
201 }
202 })
203 }
204}

Callers

nothing calls this directly

Calls 4

newFileFunction · 0.85
setStdinFunction · 0.85
ReadInputFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…