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

Function Test_NewCmdApi

pkg/cmd/api/api_test.go:30–409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func Test_NewCmdApi(t *testing.T) {
31 f := &cmdutil.Factory{}
32
33 tests := []struct {
34 name string
35 cli string
36 wants ApiOptions
37 wantsErr bool
38 }{
39 {
40 name: "no flags",
41 cli: "graphql",
42 wants: ApiOptions{
43 Hostname: "",
44 RequestMethod: "GET",
45 RequestMethodPassed: false,
46 RequestPath: "graphql",
47 RequestInputFile: "",
48 RawFields: []string(nil),
49 MagicFields: []string(nil),
50 RequestHeaders: []string(nil),
51 ShowResponseHeaders: false,
52 Paginate: false,
53 Silent: false,
54 CacheTTL: 0,
55 Template: "",
56 FilterOutput: "",
57 Verbose: false,
58 },
59 wantsErr: false,
60 },
61 {
62 name: "override method",
63 cli: "repos/octocat/Spoon-Knife -XDELETE",
64 wants: ApiOptions{
65 Hostname: "",
66 RequestMethod: "DELETE",
67 RequestMethodPassed: true,
68 RequestPath: "repos/octocat/Spoon-Knife",
69 RequestInputFile: "",
70 RawFields: []string(nil),
71 MagicFields: []string(nil),
72 RequestHeaders: []string(nil),
73 ShowResponseHeaders: false,
74 Paginate: false,
75 Silent: false,
76 CacheTTL: 0,
77 Template: "",
78 FilterOutput: "",
79 Verbose: false,
80 },
81 wantsErr: false,
82 },
83 {
84 name: "with fields",
85 cli: "graphql -f query=QUERY -F body=@file.txt",
86 wants: ApiOptions{
87 Hostname: "",

Callers

nothing calls this directly

Calls 4

NewCmdApiFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected