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

Function Test_NewCmdApi

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

Source from the content-addressed store, hash-verified

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