MCPcopy
hub / github.com/github/github-mcp-server / Test_GetMe_IFC_FeatureFlag

Function Test_GetMe_IFC_FeatureFlag

pkg/github/context_tools_test.go:142–206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func Test_GetMe_IFC_FeatureFlag(t *testing.T) {
143 t.Parallel()
144
145 serverTool := GetMe(translations.NullTranslationHelper)
146
147 mockUser := &github.User{
148 Login: github.Ptr("testuser"),
149 HTMLURL: github.Ptr("https://github.com/testuser"),
150 CreatedAt: &github.Timestamp{Time: time.Now()},
151 }
152 mockedHTTPClient := MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
153 GetUser: mockResponse(t, http.StatusOK, mockUser),
154 })
155
156 depsWithIFCFeature := func(enabled bool) *BaseDeps {
157 return NewBaseDeps(
158 mustNewGHClient(t, mockedHTTPClient), nil, nil, nil,
159 translations.NullTranslationHelper,
160 FeatureFlags{},
161 0,
162 func(_ context.Context, flagName string) (bool, error) {
163 return flagName == FeatureFlagIFCLabels && enabled, nil
164 },
165 stubExporters(),
166 )
167 }
168
169 t.Run("feature disabled omits ifc label from result meta", func(t *testing.T) {
170 deps := depsWithIFCFeature(false)
171 handler := serverTool.Handler(deps)
172
173 request := createMCPRequest(map[string]any{})
174 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
175 require.NoError(t, err)
176 require.False(t, result.IsError)
177
178 assert.Nil(t, result.Meta, "result meta should be nil when IFC labels are disabled")
179 })
180
181 t.Run("feature enabled includes ifc label in result meta", func(t *testing.T) {
182 deps := depsWithIFCFeature(true)
183 handler := serverTool.Handler(deps)
184
185 request := createMCPRequest(map[string]any{})
186 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
187 require.NoError(t, err)
188 require.False(t, result.IsError)
189
190 require.NotNil(t, result.Meta, "result meta should be set when IFC labels are enabled")
191 ifcLabel, ok := result.Meta["ifc"]
192 require.True(t, ok, "result meta should contain ifc key")
193
194 ifcJSON, err := json.Marshal(ifcLabel)
195 require.NoError(t, err)
196
197 var ifcMap map[string]any
198 err = json.Unmarshal(ifcJSON, &ifcMap)
199 require.NoError(t, err)

Callers

nothing calls this directly

Calls 9

GetMeFunction · 0.85
mockResponseFunction · 0.85
NewBaseDepsFunction · 0.85
mustNewGHClientFunction · 0.85
stubExportersFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
HandlerMethod · 0.45

Tested by

no test coverage detected