TestPRRepositorySelectionMatchesStruct guards the seam between the two: a field added to the selection but not the struct is silently dropped, and one added to the struct but not the selection is silently zero.
(t *testing.T)
| 572 | // a field added to the selection but not the struct is silently dropped, and |
| 573 | // one added to the struct but not the selection is silently zero. |
| 574 | func TestPRRepositorySelectionMatchesStruct(t *testing.T) { |
| 575 | selection := PullRequestGraphQL([]string{"repository"}) |
| 576 | inner := strings.TrimSuffix(strings.TrimPrefix(selection, "repository{"), "}") |
| 577 | selected := strings.Split(inner, ",") |
| 578 | |
| 579 | var declared []string |
| 580 | repositoryType := reflect.TypeFor[PRRepository]() |
| 581 | for field := range repositoryType.Fields() { |
| 582 | name, _, _ := strings.Cut(field.Tag.Get("json"), ",") |
| 583 | declared = append(declared, name) |
| 584 | } |
| 585 | |
| 586 | assert.ElementsMatch(t, declared, selected) |
| 587 | } |
| 588 | |
| 589 | func TestPullRequestRepositoryDatabaseID(t *testing.T) { |
| 590 | tests := []struct { |
nothing calls this directly
no test coverage detected