Skip to content

Commit

Permalink
add migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtro committed Feb 16, 2024
1 parent 9eb4733 commit c72b981
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/sentry/migrations/test_0647_apitoken_add_hashed_columns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.db import router

from sentry.silo import unguarded_write
from sentry.testutils.cases import TestMigrations
from sentry.testutils.silo import no_silo_test


@no_silo_test
class AddHashedColumnsApiToken(TestMigrations):
migrate_from = "0646_create_notification_message_table"
migrate_to = "0647_apitoken_add_hashed_columns"

def setUp(self):
from sentry.models.apitoken import ApiToken

with unguarded_write(using=router.db_for_write(ApiToken)):
super().setUp()

def setup_before_migration(self, apps):
ApiToken = apps.get_model("sentry", "ApiToken")
self.api_token = ApiToken.objects.create(
user_id=self.user.id,
)
self.api_token.save()

def test(self):
from sentry.models.apitoken import ApiToken

api_token = ApiToken.objects.get()
assert api_token.hashed_token is None
assert api_token.hashed_refresh_token is None

0 comments on commit c72b981

Please sign in to comment.