MCPcopy Index your code
hub / github.com/cli/cli / TestResolveLabels

Function TestResolveLabels

pkg/cmd/discussion/shared/labels_test.go:11–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestResolveLabels(t *testing.T) {
12 tests := []struct {
13 name string
14 allLabels []client.DiscussionLabel
15 names []string
16 wantIDs []string
17 wantErr string
18 }{
19 {
20 name: "empty source labels and empty names",
21 allLabels: nil,
22 names: nil,
23 wantIDs: nil,
24 },
25 {
26 name: "empty source labels with non-empty names",
27 allLabels: nil,
28 names: []string{"bug", "enhancement"},
29 wantErr: "labels not found: bug, enhancement",
30 },
31 {
32 name: "non-empty source labels with empty names",
33 allLabels: []client.DiscussionLabel{
34 {ID: "L1", Name: "bug"},
35 {ID: "L2", Name: "enhancement"},
36 },
37 names: nil,
38 wantIDs: nil,
39 },
40 {
41 name: "all names match",
42 allLabels: []client.DiscussionLabel{
43 {ID: "L1", Name: "bug"},
44 {ID: "L2", Name: "Enhancement"},
45 {ID: "L3", Name: "documentation"},
46 },
47 names: []string{"enhancement", "Bug"},
48 wantIDs: []string{"L2", "L1"},
49 },
50 {
51 name: "some names missing",
52 allLabels: []client.DiscussionLabel{
53 {ID: "L1", Name: "bug"},
54 {ID: "L2", Name: "enhancement"},
55 },
56 names: []string{"bug", "invalid", "unknown"},
57 wantErr: "labels not found: invalid, unknown",
58 },
59 {
60 name: "whitespace trimmed from names",
61 allLabels: []client.DiscussionLabel{
62 {ID: "L1", Name: "bug"},
63 {ID: "L2", Name: "enhancement"},
64 },
65 names: []string{" bug ", " enhancement"},
66 wantIDs: []string{"L1", "L2"},
67 },
68 }

Callers

nothing calls this directly

Calls 4

ResolveLabelsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected