Skip to content

Commit

Permalink
Alter object row IDs to force test failure in original code
Browse files Browse the repository at this point in the history
  • Loading branch information
dato committed Nov 25, 2023
1 parent e4d6886 commit 44ef928
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bookwyrm/tests/test_book_search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
""" test searching for books """
import datetime
from unittest import expectedFailure
from django.db import connection
from django.test import TestCase
from django.utils import timezone

Expand Down Expand Up @@ -153,6 +155,17 @@ def setUp(self):
self.edition.authors.add(self.author)
self.edition.save(broadcast=False)

@classmethod
def setUpTestData(cls):
"""create conditions that trigger known old bugs"""
with connection.cursor() as cursor:
cursor.execute(
"""
ALTER SEQUENCE bookwyrm_author_id_seq RESTART WITH 20;
ALTER SEQUENCE bookwyrm_book_authors_id_seq RESTART WITH 300;
"""
)

def test_search_after_changed_metadata(self):
"""book found after updating metadata"""
self.assertEqual(self.edition, self._search_first("First")) # title
Expand Down Expand Up @@ -194,6 +207,7 @@ def test_search_after_author_add(self):
self.assertEqual(self.edition, self._search_first("Mozilla"))
self.assertEqual(self.edition, self._search_first("Name"))

@expectedFailure
def test_search_after_updated_author_name(self):
"""book found under new author name"""
self.assertEqual(self.edition, self._search_first("Name"))
Expand Down

0 comments on commit 44ef928

Please sign in to comment.