Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.5k
Update integration tests for new branch protection API.#509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -114,30 +114,43 @@ func TestRepositories_EditBranches(t *testing.T) { | ||
| t.Fatalf("Repositories.GetBranch() returned error: %v", err) | ||
| } | ||
| if *branch.Protection.Enabled { | ||
| if *branch.Protected { | ||
| t.Fatalf("Branch %v of repo %v is already protected", "master", *repo.Name) | ||
| } | ||
| branch.Protection.Enabled = github.Bool(true) | ||
| branch.Protection.RequiredStatusChecks = &github.RequiredStatusChecks{ | ||
| EnforcementLevel: github.String("everyone"), | ||
| Contexts: &[]string{"continous-integration"}, | ||
| protectionRequest := &github.ProtectionRequest{ | ||
| RequiredStatusChecks: &github.RequiredStatusChecks{ | ||
| IncludeAdmins: true, | ||
| Strict: true, | ||
| Contexts: []string{"continuous-integration"}, | ||
| }, | ||
| RequiredPullRequestReviews: &github.RequiredPullRequestReviews{ | ||
| IncludeAdmins: true, | ||
| }, | ||
| // TODO: Only organization repositories can have users and team restrictions. | ||
| // In order to be able to test these Restrictions, need to add support | ||
| // for creating temporary organization repositories. | ||
| Restrictions: nil, | ||
| } | ||
| branch, _, err = client.Repositories.EditBranch(*repo.Owner.Login, *repo.Name, "master", branch) | ||
| protection, _, err := client.Repositories.UpdateBranchProtection(*repo.Owner.Login, *repo.Name, "master", protectionRequest) | ||
| if err != nil { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the blank line between the ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shurcooL I have removed the line too. | ||
| t.Fatalf("Repositories.EditBranch() returned error: %v", err) | ||
| t.Fatalf("Repositories.UpdateBranchProtection() returned error: %v", err) | ||
| } | ||
| if !*branch.Protection.Enabled { | ||
| t.Fatalf("Branch %v of repo %v should be protected, but is not!", "master", *repo.Name) | ||
| } | ||
| if *branch.Protection.RequiredStatusChecks.EnforcementLevel != "everyone" { | ||
| t.Fatalf("RequiredStatusChecks should be enabled for everyone, set for: %v", *branch.Protection.RequiredStatusChecks.EnforcementLevel) | ||
| want := &github.Protection{ | ||
| RequiredStatusChecks: &github.RequiredStatusChecks{ | ||
| IncludeAdmins: true, | ||
| Strict: true, | ||
| Contexts: []string{"continuous-integration"}, | ||
| }, | ||
| RequiredPullRequestReviews: &github.RequiredPullRequestReviews{ | ||
| IncludeAdmins: true, | ||
| }, | ||
| Restrictions: nil, | ||
| } | ||
| wantedContexts := []string{"continous-integration"} | ||
| if !reflect.DeepEqual(*branch.Protection.RequiredStatusChecks.Contexts, wantedContexts) { | ||
| t.Fatalf("RequiredStatusChecks.Contexts should be: %v but is: %v", wantedContexts, *branch.Protection.RequiredStatusChecks.Contexts) | ||
| if !reflect.DeepEqual(protection, want) { | ||
| t.Errorf("Repositories.UpdateBranchProtection() returned %+v, want %+v", protection, want) | ||
| } | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this actually passing? Just want to confirm.
| ||
| _, err = client.Repositories.Delete(*repo.Owner.Login, *repo.Name) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here. It wascontinous-integrationpreviously, but you've changed it tocontinuous-integration(extra u). I don't think that's right.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see this is actually a typo fix. Never mind, keep this as is. Sorry about my mistake.