MCPcopy
hub / github.com/cli/cli / Test_magicFieldValue

Function Test_magicFieldValue

pkg/cmd/api/fields_test.go:224–329  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

222}
223
224func Test_magicFieldValue(t *testing.T) {
225 f, err := os.CreateTemp(t.TempDir(), "gh-test")
226 if err != nil {
227 t.Fatal(err)
228 }
229 defer f.Close()
230
231 fmt.Fprint(f, "file contents")
232
233 ios, _, _, _ := iostreams.Test()
234
235 type args struct {
236 v string
237 opts *ApiOptions
238 }
239 tests := []struct {
240 name string
241 args args
242 want interface{}
243 wantErr bool
244 }{
245 {
246 name: "string",
247 args: args{v: "hello"},
248 want: "hello",
249 wantErr: false,
250 },
251 {
252 name: "bool true",
253 args: args{v: "true"},
254 want: true,
255 wantErr: false,
256 },
257 {
258 name: "bool false",
259 args: args{v: "false"},
260 want: false,
261 wantErr: false,
262 },
263 {
264 name: "null",
265 args: args{v: "null"},
266 want: nil,
267 wantErr: false,
268 },
269 {
270 name: "placeholder colon",
271 args: args{
272 v: ":owner",
273 opts: &ApiOptions{
274 IO: ios,
275 BaseRepo: func() (ghrepo.Interface, error) {
276 return ghrepo.New("hubot", "robot-uprising"), nil
277 },
278 },
279 },
280 want: "hubot",
281 wantErr: false,

Callers

nothing calls this directly

Calls 8

TestFunction · 0.92
NewFunction · 0.92
EqualMethod · 0.80
magicFieldValueFunction · 0.70
CloseMethod · 0.65
NameMethod · 0.65
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected