MCPcopy Create free account
hub / github.com/cli/cli / Test_NewCmdApi

Function Test_NewCmdApi

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

Source from the content-addressed store, hash-verified

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