up
This commit is contained in:
+8
-5
@@ -190,7 +190,7 @@ class Stand:
|
||||
wait_for(lambda: self.sql(mode, 'SELECT 1;') == '1', mode + ' PostgreSQL')
|
||||
wait_for(lambda: run('docker', 'exec', self.name + '-' + mode + '-s3', 'curl', '-fsS', 'http://127.0.0.1:9000/health') is not None, mode + ' RustFS')
|
||||
for migration in sorted((ROOT / 'evening_detective_server/migrations').glob('*.sql')):
|
||||
self.sql(mode, migration.read_text().split('-- +goose Down')[0])
|
||||
self.sql(mode, 'BEGIN;\n' + migration.read_text().split('-- +goose Down')[0] + '\nCOMMIT;')
|
||||
bootstrap = (ROOT / 'evening_detective_server/scripts/dev-user.sql').read_text()
|
||||
run('docker', 'exec', '-i', self.name + '-' + mode + '-pg', 'psql', '-U', 'test', '-d', 'test', '-v', 'ON_ERROR_STOP=1',
|
||||
'-v', 'dev_username=TEST organizer', '-v', 'dev_email=organizer@test.invalid', '-v', 'dev_password=test-only-password', input=bootstrap)
|
||||
@@ -208,6 +208,8 @@ class Stand:
|
||||
wait_for(lambda: api.request('/api/test/ping') == {}, mode + ' API')
|
||||
api.token = api.request('/api/auth/login', {'email': 'organizer@test.invalid', 'password': 'test-only-password'})['accessToken']
|
||||
assert api.request('/api/ui/permissions')['environment'] == mode
|
||||
from team_uuid import check_migration
|
||||
check_migration(lambda query: self.sql('prod', query), ROOT / 'evening_detective_server/migrations')
|
||||
self.server_thread.start()
|
||||
print('PASS: separate prod/venue DB and RustFS in internal Docker network', flush=True)
|
||||
|
||||
@@ -260,7 +262,7 @@ def fixture(stand, format):
|
||||
if participation != 'pending':
|
||||
# Simulate issuing the email token; decisions themselves use the public API.
|
||||
token = secrets.token_hex(32)
|
||||
stand.sql('prod', f"UPDATE teams SET participation_token_hash=decode('{hashlib.sha256(token.encode()).hexdigest()}', 'hex') WHERE id={int(team['ID'])};")
|
||||
stand.sql('prod', f"UPDATE teams SET participation_token_hash=decode('{hashlib.sha256(token.encode()).hexdigest()}', 'hex') WHERE id='{uuid.UUID(team['ID'])}';")
|
||||
source.request('/api/participation/answer', {'token': token, 'answer': participation})
|
||||
tickets = source.request(f'/api/games/{game}/tickets', {'count': 5})['tickets']
|
||||
used = '/api' + urllib.parse.urlparse(tickets[0]['URL']).path
|
||||
@@ -318,7 +320,8 @@ def exercise(stand, data):
|
||||
assert public.request('/api' + urllib.parse.urlparse(local_ticket['URL']).path)['ticket']['status'] == 'active'
|
||||
new_team = venue.request('/api/teams', {'gameID': game, 'name': 'TEST Local team', 'participantsCount': 2})
|
||||
data['new_team'] = new_team
|
||||
assert new_team['ID'] > max(t['ID'] for t in data['teams'])
|
||||
assert uuid.UUID(new_team['ID']).version == 7
|
||||
assert new_team['ID'] not in {t['ID'] for t in data['teams']}
|
||||
assert public.story(new_team)['game']['ID'] == game
|
||||
public.move(pending, 'p1', expected=400)
|
||||
assert next(t for t in venue.game(game)['teams'] if t['ID'] == pending['ID'])['participationStatus'] == 'pending'
|
||||
@@ -395,8 +398,8 @@ def main():
|
||||
stand.start()
|
||||
pg_address = json.loads(run('docker', 'inspect', stand.name + '-venue-pg'))[0]['NetworkSettings']['Networks'][stand.name]['IPAddress']
|
||||
run('env', f'TEST_DATABASE_URL=host={pg_address} user=test password=test-only dbname=test sslmode=disable',
|
||||
'go', 'test', './internal/services/game_service', './internal/services/gameplay_service', './internal/services/mcp_service', './internal/repos/tickets_repo', './internal/app', cwd=ROOT / 'evening_detective_server')
|
||||
print('PASS: gameplay/lifecycle/MCP/app tests with isolated PostgreSQL', flush=True)
|
||||
'go', 'test', './...', '-count=1', cwd=ROOT / 'evening_detective_server')
|
||||
print('PASS: full Go suite, independent team UUID v7 creation and registration with isolated PostgreSQL', flush=True)
|
||||
prod_address = json.loads(run('docker', 'inspect', stand.name + '-prod-pg'))[0]['NetworkSettings']['Networks'][stand.name]['IPAddress']
|
||||
run('env', f'TEST_DATABASE_URL=host={prod_address} user=test password=test-only dbname=test sslmode=disable',
|
||||
'go', 'test', '-race', './internal/services/game_export_service', './internal/services/game_results_package_service', './internal/repos/game_returns_repo', '-count=1', cwd=ROOT / 'evening_detective_server')
|
||||
|
||||
Reference in New Issue
Block a user