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

Function TestResolveFieldByID

pkg/cmd/project/shared/queries/resolve_fields_test.go:75–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestResolveFieldByID(t *testing.T) {
76 fields := []ProjectField{
77 textField("PVTF_title", "Title"),
78 singleSelectField("PVTSSF_status", "Status", nil),
79 textField("PVTF_prio", "Priority"),
80 }
81
82 t.Run("resolves an exact id match", func(t *testing.T) {
83 got, err := ResolveFieldByID(fields, "PVTSSF_status")
84 require.NoError(t, err)
85 assert.Equal(t, "Status", got.Name())
86 })
87
88 t.Run("not found lists candidate name (id) pairs", func(t *testing.T) {
89 _, err := ResolveFieldByID(fields, "PVTF_missing")
90 require.Error(t, err)
91 var nf *FieldIDNotFoundError
92 require.True(t, errors.As(err, &nf))
93 assert.Equal(t, "PVTF_missing", nf.ID)
94 assert.Equal(t, []string{"Priority (PVTF_prio)", "Status (PVTSSF_status)", "Title (PVTF_title)"}, nf.Candidates)
95 assert.Contains(t, err.Error(), "available fields: Priority (PVTF_prio), Status (PVTSSF_status), Title (PVTF_title)")
96 })
97}

Callers

nothing calls this directly

Calls 8

textFieldFunction · 0.85
singleSelectFieldFunction · 0.85
ResolveFieldByIDFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
RunMethod · 0.65
NameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected