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

Function TestCompleteEventTypes

pkg/cmd/event/shared/completion_test.go:9–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestCompleteEventTypes(t *testing.T) {
10 const (
11 review = "com.github.pull_request.review.submitted.v1\ta review was submitted"
12 head = "com.github.pull_request.head.changed.v1\tthe head branch changed, for example after a push"
13 checks = "com.github.pull_request.check_suite.status.changed.v1\ta check suite on the head commit completed, such as a CI workflow"
14 )
15
16 tests := []struct {
17 name string
18 toComplete string
19 want []string
20 }{
21 {
22 name: "matches by prefix",
23 toComplete: "com.github.pull_request.re",
24 want: []string{review},
25 },
26 {
27 name: "matches a check suite event",
28 toComplete: "com.github.pull_request.ch",
29 want: []string{checks},
30 },
31 {
32 name: "completes the last item and skips the chosen ones",
33 toComplete: "com.github.pull_request.review.submitted.v1,com.github.pull_request.he",
34 want: []string{"com.github.pull_request.review.submitted.v1," + head},
35 },
36 {
37 name: "leaves out a type already chosen",
38 toComplete: "com.github.pull_request.review.submitted.v1,com.github.pull_request.review",
39 want: nil,
40 },
41 {
42 name: "suggests nothing for an unknown type",
43 toComplete: "com.github.issue",
44 want: nil,
45 },
46 }
47 for _, tt := range tests {
48 t.Run(tt.name, func(t *testing.T) {
49 assert.Equal(t, tt.want, CompleteEventTypes(tt.toComplete))
50 })
51 }
52}

Callers

nothing calls this directly

Calls 3

CompleteEventTypesFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected