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

Function TestRepositoryFeatures

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

Source from the content-addressed store, hash-verified

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