Skip to content

Commit c01afd3

Browse files
feat(tests): add PostgreSQL and SQLite support for atomic transaction tests
1 parent b7460d1 commit c01afd3

5 files changed

Lines changed: 610 additions & 322 deletions

File tree

.env.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ FASTAPI__SWAGGER_UI_PARAMS={}
1818
# Testcontainers Configuration
1919
TESTCONTAINERS_RYUK_CONTAINER_IMAGE=testcontainers/ryuk:0.14.0
2020

21+
# Temporal Configuration
22+
TEMPORAL__IMAGE=temporalio/auto-setup:1.29.1
23+
TEMPORAL__HOST=localhost
24+
TEMPORAL__PORT=7233
25+
TEMPORAL__NAMESPACE=default
26+
TEMPORAL__TASK_QUEUE=test-task-queue
27+
2128
# Redis Configuration
2229
REDIS__IMAGE=redis:8.4.0-alpine
2330
REDIS__MASTER_HOST=localhost:6379
Lines changed: 97 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,143 @@
11
@needs-postgres
22
Feature: SQLAlchemy Atomic Transactions
33

4-
Background:
5-
Given the application database is initialized
4+
Scenario Outline: Create and retrieve entity in atomic transaction
5+
Given the application database is initialized for <db_type>
66
And test entities are defined
7-
8-
Scenario: Create and retrieve entity in atomic transaction
97
When a new entity is created in an atomic transaction
108
Then the entity should be retrievable
119

12-
Scenario: Handle transaction rollback on exception
10+
Examples:
11+
| db_type |
12+
| postgres|
13+
| sqlite |
14+
15+
Scenario Outline: Handle transaction rollback on exception
16+
Given the application database is initialized for <db_type>
17+
And test entities are defined
1318
When a new entity creation fails within an atomic transaction
1419
Then no entity should exist in the database
1520
And the database session should remain usable
1621

17-
Scenario: Support nested atomic transactions
22+
Examples:
23+
| db_type |
24+
| postgres|
25+
| sqlite |
26+
27+
Scenario Outline: Support nested atomic transactions
28+
Given the application database is initialized for <db_type>
29+
And test entities are defined
1830
When nested atomic transactions are executed
19-
Then operations from successful nested transactions should not be committed
31+
Then operations from successful nested transactions should be visible within outer transaction
2032
And operations from failed nested transactions should be rolled back
2133

22-
Scenario: Update entities in atomic transaction
23-
Given an entity exists in the database
34+
Examples:
35+
| db_type |
36+
| postgres|
37+
| sqlite |
38+
39+
Scenario Outline: Update entities in atomic transaction
40+
Given the application database is initialized for <db_type>
41+
And test entities are defined
42+
And an entity exists in the database
2443
When the entity is updated within an atomic transaction
2544
Then the entity properties should reflect the updates
2645

27-
Scenario: Create entities with relationships in atomic transaction
46+
Examples:
47+
| db_type |
48+
| postgres|
49+
| sqlite |
50+
51+
Scenario Outline: Create entities with relationships in atomic transaction
52+
Given the application database is initialized for <db_type>
53+
And test entities are defined
2854
When an entity with relationships is created in an atomic transaction
2955
Then the entity and its relationships should be retrievable
3056

31-
Scenario: Support different entity types in atomic transactions
57+
Examples:
58+
| db_type |
59+
| postgres|
60+
| sqlite |
61+
62+
Scenario Outline: Support different entity types in atomic transactions
63+
Given the application database is initialized for <db_type>
64+
And test entities are defined
3265
When different types of entities are created in an atomic transaction
3366
Then all entity types should be retrievable
3467

35-
Scenario: Test error handling in atomic transactions
68+
Examples:
69+
| db_type |
70+
| postgres|
71+
| sqlite |
72+
73+
Scenario Outline: Test error handling in atomic transactions
74+
Given the application database is initialized for <db_type>
75+
And test entities are defined
3676
When an error is triggered within an atomic transaction
3777
Then the appropriate error should be raised
3878
And the transaction should be rolled back
3979

40-
Scenario: Verify session consistency across multiple atomic blocks
80+
Examples:
81+
| db_type |
82+
| postgres|
83+
| sqlite |
84+
85+
Scenario Outline: Verify session consistency across multiple atomic blocks
86+
Given the application database is initialized for <db_type>
87+
And test entities are defined
4188
When operations are performed across multiple atomic blocks
4289
Then session should maintain consistency across atomic blocks
4390

91+
Examples:
92+
| db_type |
93+
| postgres|
94+
| sqlite |
95+
4496
@async
45-
Scenario: Create and retrieve entity in async atomic transaction
97+
Scenario Outline: Create and retrieve entity in async atomic transaction
98+
Given the application database is initialized for <db_type>
99+
And test entities are defined
46100
When a new entity is created in an async atomic transaction
47101
Then the async entity should be retrievable
48102

103+
Examples:
104+
| db_type |
105+
| postgres|
106+
| sqlite |
107+
49108
@async
50-
Scenario: Handle transaction rollback in async atomic transaction
109+
Scenario Outline: Handle transaction rollback in async atomic transaction
110+
Given the application database is initialized for <db_type>
111+
And test entities are defined
51112
When a new async entity creation fails within an atomic transaction
52113
Then no async entity should exist in the database
53114
And the async database session should remain usable
54115

116+
Examples:
117+
| db_type |
118+
| postgres|
119+
| sqlite |
120+
55121
@async
56-
Scenario: Create multiple entities in async atomic transaction
122+
Scenario Outline: Create multiple entities in async atomic transaction
123+
Given the application database is initialized for <db_type>
124+
And test entities are defined
57125
When multiple entities are created in an async atomic transaction
58126
Then all async entities should be retrievable
59127

128+
Examples:
129+
| db_type |
130+
| postgres|
131+
| sqlite |
132+
60133
@async
61-
Scenario: Create and manage complex entity relationships asynchronously
134+
Scenario Outline: Create and manage complex entity relationships asynchronously
135+
Given the application database is initialized for <db_type>
136+
And test entities are defined
62137
When complex async operations are performed in a transaction
63138
Then all related entities should be accessible
139+
140+
Examples:
141+
| db_type |
142+
| postgres|
143+
| sqlite |

0 commit comments

Comments
 (0)