MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / TestFeatureSetOrder

Function TestFeatureSetOrder

mcp/features_test.go:20–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestFeatureSetOrder(t *testing.T) {
21 toolA := &Tool{Name: "apple", Description: "apple tool"}
22 toolB := &Tool{Name: "banana", Description: "banana tool"}
23 toolC := &Tool{Name: "cherry", Description: "cherry tool"}
24
25 testCases := []struct {
26 tools []*Tool
27 want []*Tool
28 }{
29 {[]*Tool{toolA, toolB, toolC}, []*Tool{toolA, toolB, toolC}},
30 {[]*Tool{toolB, toolC, toolA}, []*Tool{toolA, toolB, toolC}},
31 {[]*Tool{toolA, toolC}, []*Tool{toolA, toolC}},
32 {[]*Tool{toolA, toolA, toolA}, []*Tool{toolA}},
33 {[]*Tool{}, nil},
34 }
35 for _, tc := range testCases {
36 fs := newFeatureSet(func(t *Tool) string { return t.Name })
37 fs.add(tc.tools...)
38 got := slices.Collect(fs.all())
39 if diff := cmp.Diff(got, tc.want, cmpopts.IgnoreUnexported(jsonschema.Schema{})); diff != "" {
40 t.Errorf("expected %v, got %v, (-want +got):\n%s", tc.want, got, diff)
41 }
42 }
43}
44
45func TestFeatureSetAbove(t *testing.T) {
46 toolA := &Tool{Name: "apple", Description: "apple tool"}

Callers

nothing calls this directly

Calls 3

newFeatureSetFunction · 0.85
addMethod · 0.80
allMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…