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

Function TestParseKeys

script/ghmock/terminal_test.go:10–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestParseKeys(t *testing.T) {
11 tests := []struct {
12 name string
13 in string
14 want string
15 wantErr string
16 }{
17 {name: "text and a named key", in: "my-repo{enter}", want: "my-repo\r"},
18 {name: "arrows and space", in: "{down}{down}{space}{enter}", want: "\x1b[B\x1b[B \r"},
19 {name: "key names ignore case", in: "{Enter}", want: "\r"},
20 {name: "a doubled brace types a brace", in: "a{{b}", want: "a{b}"},
21 {name: "nothing", in: "", want: ""},
22 {name: "a brace without its end", in: "{enter", wantErr: `--keys "{enter" has a { without a }; type a brace as {{`},
23 }
24 for _, tt := range tests {
25 t.Run(tt.name, func(t *testing.T) {
26 got, err := parseKeys(tt.in)
27 if tt.wantErr != "" {
28 require.EqualError(t, err, tt.wantErr)
29 return
30 }
31 require.NoError(t, err)
32 assert.Equal(t, tt.want, got)
33 })
34 }
35}

Callers

nothing calls this directly

Calls 3

parseKeysFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected