sql: test purge of search tokens (#86527)
gitea/wcs/pipeline/head There was a failure building this commit
Details
gitea/wcs/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
f9c2866ba9
commit
fc6e252770
|
@ -1183,6 +1183,45 @@ def test_sql_criteria_fts(pub):
|
||||||
assert data_class.select([st.FtsMatch(formdata1.id_display)])[0].id_display == formdata1.id_display
|
assert data_class.select([st.FtsMatch(formdata1.id_display)])[0].id_display == formdata1.id_display
|
||||||
|
|
||||||
|
|
||||||
|
def test_search_tokens_purge(pub):
|
||||||
|
_, cur = sql.get_connection_and_cursor()
|
||||||
|
|
||||||
|
# purge garbage from other tests
|
||||||
|
sql.purge_obsolete_search_tokens()
|
||||||
|
|
||||||
|
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
|
||||||
|
start = cur.fetchone()[0]
|
||||||
|
|
||||||
|
# define a new table
|
||||||
|
test_formdef = FormDef()
|
||||||
|
test_formdef.name = 'tableSelectFTStokens'
|
||||||
|
test_formdef.fields = [fields.StringField(id='3', label='string')]
|
||||||
|
test_formdef.store()
|
||||||
|
data_class = test_formdef.data_class(mode='sql')
|
||||||
|
|
||||||
|
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
|
||||||
|
assert cur.fetchone()[0] == start+1
|
||||||
|
|
||||||
|
t = data_class()
|
||||||
|
t.data = {'3': 'foofortokensofcourse'}
|
||||||
|
t.just_created()
|
||||||
|
t.store()
|
||||||
|
|
||||||
|
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
|
||||||
|
assert cur.fetchone()[0] == start+2
|
||||||
|
|
||||||
|
t.data = {'3': 'chaussettefortokensofcourse'}
|
||||||
|
t.store()
|
||||||
|
|
||||||
|
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
|
||||||
|
assert cur.fetchone()[0] == start+3
|
||||||
|
|
||||||
|
sql.purge_obsolete_search_tokens()
|
||||||
|
|
||||||
|
cur.execute('SELECT count(*) FROM wcs_search_tokens;')
|
||||||
|
assert cur.fetchone()[0] == start+2
|
||||||
|
|
||||||
|
|
||||||
def table_exists(cur, table_name):
|
def table_exists(cur, table_name):
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''SELECT COUNT(*) FROM information_schema.tables
|
'''SELECT COUNT(*) FROM information_schema.tables
|
||||||
|
|
Loading…
Reference in New Issue