Skip to content

Commit c689c09

Browse files
authored
fix(tests): Fix flaky GitHub webhook test ordering (#97676)
Replace order-dependent assertions with set comparison to verify both organizations have repositories. Make other improvements to the test. Fixes GH-96766. ### Legal Boilerplate Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
1 parent 980ead9 commit c689c09

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/sentry/integrations/github/test_webhooks.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,12 @@ def test_multiple_orgs_creates_missing_repo(self, mock_metrics: MagicMock) -> No
735735
future_expires = datetime.now().replace(microsecond=0) + timedelta(minutes=5)
736736
with assume_test_silo_mode(SiloMode.CONTROL):
737737
integration = self.create_integration(
738-
organization=project.organization.id,
738+
organization=project.organization,
739739
external_id="12345",
740740
provider="github",
741741
metadata={"access_token": "1234", "expires_at": future_expires.isoformat()},
742742
)
743743
integration.add_organization(org2.id, self.user)
744-
integration.add_organization(org2.id, self.user)
745744

746745
response = self.client.post(
747746
path=self.url,
@@ -756,14 +755,16 @@ def test_multiple_orgs_creates_missing_repo(self, mock_metrics: MagicMock) -> No
756755
assert response.status_code == 204
757756

758757
repos = Repository.objects.all()
758+
759759
assert len(repos) == 2
760760

761-
assert repos[0].organization_id == project.organization.id
762-
assert repos[1].organization_id == org2.id
761+
assert {repo.organization_id for repo in repos} == {project.organization.id, org2.id}
762+
763763
for repo in repos:
764764
assert repo.external_id == "35129377"
765765
assert repo.provider == "integrations:github"
766766
assert repo.name == "baxterthehacker/public-repo"
767+
767768
mock_metrics.incr.assert_any_call("github.webhook.repository_created")
768769

769770
def test_multiple_orgs_ignores_hidden_repo(self) -> None:

0 commit comments

Comments
 (0)