Skip to content

Commit ab7a4e4

Browse files
test: convert Redis tests to scenario outlines for mock and container testing
1 parent 67ba54d commit ab7a4e4

5 files changed

Lines changed: 320 additions & 229 deletions

File tree

.env.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ STARROCKS_SQLALCHEMY__USERNAME=root
4949
STARROCKS_SQLALCHEMY__PASSWORD=
5050

5151
# Keycloak Configuration
52-
KEYCLOAK__IMAGE=quay.io/keycloak/keycloak:26.5.2
52+
KEYCLOAK__IMAGE=quay.io/keycloak/keycloak:26.5.3
5353
KEYCLOAK__SERVER_URL=http://localhost:8080
5454
KEYCLOAK__ADMIN_USERNAME=admin
5555
KEYCLOAK__ADMIN_PASSWORD=admin

features/redis_mock.feature

Lines changed: 96 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,137 @@
1-
Feature: Redis Mock Testing
1+
@needs-redis
2+
Feature: Redis Testing
23
As a developer
3-
I want to have reliable Redis mocks for testing
4-
So that I can write tests without a real Redis server
4+
I want to test Redis operations with both mocks and real containers
5+
So that I can ensure compatibility and reliability across different environments
56

67
Background:
78
Given test entities are defined
89

9-
Scenario: Store and retrieve a simple key-value pair with Redis mock
10-
Given a configured Redis mock
11-
When I store the key "user-id" with value "12345" in Redis mock
10+
Scenario Outline: Store and retrieve a simple key-value pair
11+
Given a configured <adapter_type>
12+
When I store the key "user-id" with value "12345" in <adapter_type>
1213
Then the sync store operation should succeed
13-
When I retrieve the value for key "user-id" from Redis mock
14+
When I retrieve the value for key "user-id" from <adapter_type>
1415
Then the sync retrieved value should be "12345"
1516

16-
Scenario: Remove a key with Redis mock
17-
Given a configured Redis mock
18-
When I store the key "session-token" with value "abcde" in Redis mock
17+
Examples: Adapter Types
18+
| adapter_type |
19+
| mock |
20+
| container |
21+
22+
Scenario Outline: Remove a key
23+
Given a configured <adapter_type>
24+
When I store the key "session-token" with value "abcde" in <adapter_type>
1925
Then the sync store operation should succeed
20-
When I remove the key "session-token" from Redis mock
26+
When I remove the key "session-token" from <adapter_type>
2127
Then the sync remove operation should delete one key
22-
When I check if "session-token" exists in Redis mock
28+
When I check if "session-token" exists in <adapter_type>
2329
Then the sync key should not exist
2430

25-
Scenario: Manage a list of items with Redis mock
26-
Given a configured Redis mock
27-
When I add "apple, banana, orange" to the list "fruits" in Redis mock
31+
Examples: Adapter Types
32+
| adapter_type |
33+
| mock |
34+
| container |
35+
36+
Scenario Outline: Manage a list of items
37+
Given a configured <adapter_type>
38+
When I add "apple, banana, orange" to the list "fruits" in <adapter_type>
2839
Then the sync list "fruits" should have 3 items
29-
When I fetch all items from the list "fruits" in Redis mock
40+
When I fetch all items from the list "fruits" in <adapter_type>
3041
Then the sync list "fruits" should contain "apple, banana, orange"
3142

32-
Scenario: Handle a hash structure with Redis mock
33-
Given a configured Redis mock
34-
When I assign "name" to "Alice" in the hash "profile" in Redis mock
43+
Examples: Adapter Types
44+
| adapter_type |
45+
| mock |
46+
| container |
47+
48+
Scenario Outline: Handle a hash structure
49+
Given a configured <adapter_type>
50+
When I assign "name" to "Alice" in the hash "profile" in <adapter_type>
3551
Then the sync hash assignment should succeed
36-
When I retrieve the "name" field from the hash "profile" in Redis mock
52+
When I retrieve the "name" field from the hash "profile" in <adapter_type>
3753
Then the sync retrieved field value should be "Alice"
3854

39-
Scenario: Manage a set of colors with Redis mock
40-
Given a configured Redis mock
41-
When I add "red, blue, green" to the set "colors" in Redis mock
55+
Examples: Adapter Types
56+
| adapter_type |
57+
| mock |
58+
| container |
59+
60+
Scenario Outline: Manage a set of colors
61+
Given a configured <adapter_type>
62+
When I add "red, blue, green" to the set "colors" in <adapter_type>
4263
Then the sync set "colors" should have 3 members
43-
When I fetch all members from the set "colors" in Redis mock
64+
When I fetch all members from the set "colors" in <adapter_type>
4465
Then the sync set "colors" should contain "red, blue, green"
4566

67+
Examples: Adapter Types
68+
| adapter_type |
69+
| mock |
70+
| container |
71+
4672
@async
47-
Scenario: Store and retrieve a key-value pair asynchronously with Redis mock
48-
Given a configured async Redis mock
49-
When I store the key "order-id" with value "67890" in async Redis mock
73+
Scenario Outline: Store and retrieve a key-value pair asynchronously
74+
Given a configured async <adapter_type>
75+
When I store the key "order-id" with value "67890" in async <adapter_type>
5076
Then the async store operation should succeed
51-
When I retrieve the value for key "order-id" from async Redis mock
77+
When I retrieve the value for key "order-id" from async <adapter_type>
5278
Then the async retrieved value should be "67890"
5379

80+
Examples: Adapter Types
81+
| adapter_type |
82+
| mock |
83+
| container |
84+
5485
@async
55-
Scenario: Remove a key asynchronously with Redis mock
56-
Given a configured async Redis mock
57-
When I store the key "cache-key" with value "xyz" in async Redis mock
86+
Scenario Outline: Remove a key asynchronously
87+
Given a configured async <adapter_type>
88+
When I store the key "cache-key" with value "xyz" in async <adapter_type>
5889
Then the async store operation should succeed
59-
When I remove the key "cache-key" from async Redis mock
90+
When I remove the key "cache-key" from async <adapter_type>
6091
Then the async remove operation should delete one key
61-
When I check if "cache-key" exists in async Redis mock
92+
When I check if "cache-key" exists in async <adapter_type>
6293
Then the async key should not exist
6394

95+
Examples: Adapter Types
96+
| adapter_type |
97+
| mock |
98+
| container |
99+
64100
@async
65-
Scenario: Manage a list of tasks asynchronously with Redis mock
66-
Given a configured async Redis mock
67-
When I add "task1, task2, task3" to the list "tasks" in async Redis mock
101+
Scenario Outline: Manage a list of tasks asynchronously
102+
Given a configured async <adapter_type>
103+
When I add "task1, task2, task3" to the list "tasks" in async <adapter_type>
68104
Then the async list "tasks" should have 3 items
69-
When I fetch all items from the list "tasks" in async Redis mock
105+
When I fetch all items from the list "tasks" in async <adapter_type>
70106
Then the async list "tasks" should contain "task1, task2, task3"
71107

108+
Examples: Adapter Types
109+
| adapter_type |
110+
| mock |
111+
| container |
112+
72113
@async
73-
Scenario: Handle a hash structure asynchronously with Redis mock
74-
Given a configured async Redis mock
75-
When I assign "email" to "bob@example.com" in the hash "contact" in async Redis mock
114+
Scenario Outline: Handle a hash structure asynchronously
115+
Given a configured async <adapter_type>
116+
When I assign "email" to "bob@example.com" in the hash "contact" in async <adapter_type>
76117
Then the async hash assignment should succeed
77-
When I retrieve the "email" field from the hash "contact" in async Redis mock
118+
When I retrieve the "email" field from the hash "contact" in async <adapter_type>
78119
Then the async retrieved field value should be "bob@example.com"
79120

121+
Examples: Adapter Types
122+
| adapter_type |
123+
| mock |
124+
| container |
125+
80126
@async
81-
Scenario: Manage a set of tags asynchronously with Redis mock
82-
Given a configured async Redis mock
83-
When I add "tag1, tag2, tag3" to the set "tags" in async Redis mock
127+
Scenario Outline: Manage a set of tags asynchronously
128+
Given a configured async <adapter_type>
129+
When I add "tag1, tag2, tag3" to the set "tags" in async <adapter_type>
84130
Then the async set "tags" should have 3 members
85-
When I fetch all members from the set "tags" in async Redis mock
131+
When I fetch all members from the set "tags" in async <adapter_type>
86132
Then the async set "tags" should contain "tag1, tag2, tag3"
133+
134+
Examples: Adapter Types
135+
| adapter_type |
136+
| mock |
137+
| container |

0 commit comments

Comments
 (0)