MCPcopy
hub / github.com/cli/cli / TestRepositoryFeatures

Function TestRepositoryFeatures

internal/featuredetection/feature_detection_test.go:270–374  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

268}
269
270func TestRepositoryFeatures(t *testing.T) {
271 tests := []struct {
272 name string
273 hostname string
274 queryResponse map[string]string
275 wantFeatures RepositoryFeatures
276 wantErr bool
277 }{
278 {
279 name: "github.com",
280 hostname: "github.com",
281 wantFeatures: RepositoryFeatures{
282 PullRequestTemplateQuery: true,
283 VisibilityField: true,
284 AutoMerge: true,
285 },
286 wantErr: false,
287 },
288 {
289 name: "ghec data residency (ghe.com)",
290 hostname: "stampname.ghe.com",
291 wantFeatures: RepositoryFeatures{
292 PullRequestTemplateQuery: true,
293 VisibilityField: true,
294 AutoMerge: true,
295 },
296 wantErr: false,
297 },
298 {
299 name: "GHE empty response",
300 hostname: "git.my.org",
301 queryResponse: map[string]string{
302 `query Repository_fields\b`: `{"data": {}}`,
303 },
304 wantFeatures: RepositoryFeatures{
305 PullRequestTemplateQuery: false,
306 },
307 wantErr: false,
308 },
309 {
310 name: "GHE has pull request template query",
311 hostname: "git.my.org",
312 queryResponse: map[string]string{
313 `query Repository_fields\b`: heredoc.Doc(`
314 { "data": { "Repository": { "fields": [
315 {"name": "pullRequestTemplates"}
316 ] } } }
317 `),
318 },
319 wantFeatures: RepositoryFeatures{
320 PullRequestTemplateQuery: true,
321 },
322 wantErr: false,
323 },
324 {
325 name: "GHE has visibility field",
326 hostname: "git.my.org",
327 queryResponse: map[string]string{

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
RepositoryFeaturesMethod · 0.95
ReplaceTripperFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected