From e5c363397a520e553beaadc9816b280c98378c6e Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 20 Sep 2022 15:32:43 -0400 Subject: [PATCH] fix flaky test that only is flaky on postgres --- bin/recreate_db | 6 +++--- tests/spiffworkflow_backend/unit/test_message_service.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/recreate_db b/bin/recreate_db index 5a1aa3f7..ecb8fbfc 100755 --- a/bin/recreate_db +++ b/bin/recreate_db @@ -29,10 +29,10 @@ if [[ "${1:-}" == "clean" ]]; then if [[ "${SPIFF_DATABASE_TYPE:-}" == "postgres" ]]; then if ! docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_testing -c "select 1"; then docker run --name postgres-spiff -p 5432:5432 -e POSTGRES_PASSWORD=spiffworkflow_backend -e POSTGRES_USER=spiffworkflow_backend -e POSTGRES_DB=spiffworkflow_backend_testing -d postgres - sleep 4 # classy - - # create other db + fi + if ! docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_development -c "select 1"; then + # create other db. spiffworkflow_backend_testing came with the docker run. docker exec -it postgres-spiff psql -U spiffworkflow_backend spiffworkflow_backend_testing -c "create database spiffworkflow_backend_development;" fi fi diff --git a/tests/spiffworkflow_backend/unit/test_message_service.py b/tests/spiffworkflow_backend/unit/test_message_service.py index 3b796120..fe72c926 100644 --- a/tests/spiffworkflow_backend/unit/test_message_service.py +++ b/tests/spiffworkflow_backend/unit/test_message_service.py @@ -188,8 +188,10 @@ class TestMessageService(BaseTest): process_instance_result = ProcessInstanceModel.query.all() assert len(process_instance_result) == 3 - process_instance_receiver_one = process_instance_result[1] - process_instance_receiver_two = process_instance_result[2] + process_instance_receiver_one = ProcessInstanceModel.query.filter_by(process_model_identifier='message_receiver_one').first() + assert process_instance_receiver_one is not None + process_instance_receiver_two = ProcessInstanceModel.query.filter_by(process_model_identifier='message_receiver_two').first() + assert process_instance_receiver_two is not None # just make sure it's a different process instance assert (