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

Function TestParseSchemaArgs

script/ghmock/schemacmd_test.go:13–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestParseSchemaArgs(t *testing.T) {
14 tests := []struct {
15 name string
16 args []string
17 want schemaOptions
18 wantErr string
19 }{
20 {
21 name: "GraphQL type",
22 args: []string{"Issue"},
23 want: schemaOptions{name: "Issue"},
24 },
25 {
26 name: "REST request with flags",
27 args: []string{"GET /repos/octo/hello", "--at", "owner.login", "--status", "404"},
28 want: schemaOptions{name: "GET /repos/octo/hello", at: "owner.login", status: 404},
29 },
30 {
31 name: "flags first, then name",
32 args: []string{"--status", "404", "GET /repos/octo/hello"},
33 want: schemaOptions{name: "GET /repos/octo/hello", status: 404},
34 },
35 {
36 name: "missing name",
37 wantErr: `missing name, such as Issue, Issue.title or "GET /repos/octo/hello"`,
38 },
39 {
40 name: "GraphQL request name",
41 args: []string{"graphql IssueByNumber"},
42 wantErr: "look up GraphQL types and fields by name, such as Issue or Issue.title",
43 },
44 {
45 name: "REST flags on a GraphQL name",
46 args: []string{"Issue", "--at", "title"},
47 wantErr: "--at and --status are for REST requests; look up a GraphQL field as Type.field",
48 },
49 {
50 name: "status out of range",
51 args: []string{"GET /", "--status", "99"},
52 wantErr: "--status must be between 100 and 599",
53 },
54 {
55 name: "lowercase method",
56 args: []string{"get /repos"},
57 wantErr: `request name "get /repos" must start with an uppercase HTTP method or "graphql"`,
58 },
59 {
60 name: "unquoted REST name",
61 args: []string{"GET", "/repos/octo/hello"},
62 wantErr: "unexpected arguments: /repos/octo/hello; quote the request name, such as 'GET /repos/octo/hello'",
63 },
64 {
65 name: "extra arguments",
66 args: []string{"Issue", "extra"},
67 wantErr: "unexpected arguments: extra",
68 },
69 }
70

Callers

nothing calls this directly

Calls 3

parseSchemaArgsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected