@@ -46,7 +46,10 @@ impl ResolverTester {
46
46
#[ tokio:: test( flavor = "multi_thread" ) ]
47
47
async fn if_single_static_provider_with_no_key_to_resolve_is_valid ( ) -> anyhow:: Result < ( ) > {
48
48
let resolver = ResolverTester :: new ( )
49
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
49
+ . with_provider ( StaticProvider :: with_variable (
50
+ "database_host" ,
51
+ Some ( "localhost" ) ,
52
+ ) )
50
53
. make_resolver ( ) ?;
51
54
52
55
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -58,8 +61,11 @@ async fn if_single_static_provider_with_no_key_to_resolve_is_valid() -> anyhow::
58
61
async fn if_single_static_provider_has_data_for_variable_key_to_resolve_it_succeeds (
59
62
) -> anyhow:: Result < ( ) > {
60
63
let resolver = ResolverTester :: new ( )
61
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
62
- . with_variable ( "foo" , None )
64
+ . with_provider ( StaticProvider :: with_variable (
65
+ "database_host" ,
66
+ Some ( "localhost" ) ,
67
+ ) )
68
+ . with_variable ( "database_host" , None )
63
69
. make_resolver ( ) ?;
64
70
65
71
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -71,8 +77,11 @@ async fn if_single_static_provider_has_data_for_variable_key_to_resolve_it_succe
71
77
async fn if_there_is_a_single_static_provider_and_it_does_not_contain_a_required_variable_then_validation_fails (
72
78
) -> anyhow:: Result < ( ) > {
73
79
let resolver = ResolverTester :: new ( )
74
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
75
- . with_variable ( "bar" , None )
80
+ . with_provider ( StaticProvider :: with_variable (
81
+ "database_host" ,
82
+ Some ( "localhost" ) ,
83
+ ) )
84
+ . with_variable ( "api_key" , None )
76
85
. make_resolver ( ) ?;
77
86
78
87
assert ! ( resolver. ensure_required_variables_resolved( ) . await . is_err( ) ) ;
@@ -85,7 +94,7 @@ async fn if_there_is_a_dynamic_provider_then_validation_succeeds_even_without_de
85
94
) -> anyhow:: Result < ( ) > {
86
95
let resolver = ResolverTester :: new ( )
87
96
. with_provider ( DynamicProvider )
88
- . with_variable ( "bar " , None )
97
+ . with_variable ( "api_key " , None )
89
98
. make_resolver ( ) ?;
90
99
91
100
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -98,8 +107,11 @@ async fn if_there_is_a_dynamic_provider_and_static_provider_but_the_variable_to_
98
107
) -> anyhow:: Result < ( ) > {
99
108
let resolver = ResolverTester :: new ( )
100
109
. with_provider ( DynamicProvider )
101
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
102
- . with_variable ( "baz" , None )
110
+ . with_provider ( StaticProvider :: with_variable (
111
+ "database_host" ,
112
+ Some ( "localhost" ) ,
113
+ ) )
114
+ . with_variable ( "api_key" , None )
103
115
. make_resolver ( ) ?;
104
116
105
117
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -112,8 +124,11 @@ async fn if_there_is_a_dynamic_provider_and_a_static_provider_then_validation_su
112
124
) -> anyhow:: Result < ( ) > {
113
125
let resolver = ResolverTester :: new ( )
114
126
. with_provider ( DynamicProvider )
115
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
116
- . with_variable ( "baz" , Some ( "coo" ) )
127
+ . with_provider ( StaticProvider :: with_variable (
128
+ "database_host" ,
129
+ Some ( "localhost" ) ,
130
+ ) )
131
+ . with_variable ( "api_key" , Some ( "super-secret-key" ) )
117
132
. make_resolver ( ) ?;
118
133
119
134
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -124,9 +139,15 @@ async fn if_there_is_a_dynamic_provider_and_a_static_provider_then_validation_su
124
139
#[ tokio:: test( flavor = "multi_thread" ) ]
125
140
async fn if_there_are_two_static_providers_where_one_has_data_is_valid ( ) -> anyhow:: Result < ( ) > {
126
141
let resolver = ResolverTester :: new ( )
127
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
128
- . with_provider ( StaticProvider :: with_variable ( "baz" , Some ( "hay" ) ) )
129
- . with_variable ( "foo" , None )
142
+ . with_provider ( StaticProvider :: with_variable (
143
+ "database_host" ,
144
+ Some ( "localhost" ) ,
145
+ ) )
146
+ . with_provider ( StaticProvider :: with_variable (
147
+ "api_key" ,
148
+ Some ( "super-secret-key" ) ,
149
+ ) )
150
+ . with_variable ( "database_host" , None )
130
151
. make_resolver ( ) ?;
131
152
132
153
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -140,9 +161,15 @@ async fn if_there_are_two_static_providers_where_one_has_data_is_valid() -> anyh
140
161
async fn if_there_are_two_static_providers_where_first_provider_does_not_have_data_while_second_provider_does (
141
162
) -> anyhow:: Result < ( ) > {
142
163
let resolver = ResolverTester :: new ( )
143
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
144
- . with_provider ( StaticProvider :: with_variable ( "baz" , Some ( "hay" ) ) )
145
- . with_variable ( "baz" , None )
164
+ . with_provider ( StaticProvider :: with_variable (
165
+ "database_host" ,
166
+ Some ( "localhost" ) ,
167
+ ) )
168
+ . with_provider ( StaticProvider :: with_variable (
169
+ "api_key" ,
170
+ Some ( "super-secret-key" ) ,
171
+ ) )
172
+ . with_variable ( "api_key" , None )
146
173
. make_resolver ( ) ?;
147
174
148
175
resolver. ensure_required_variables_resolved ( ) . await ?;
@@ -153,8 +180,14 @@ async fn if_there_are_two_static_providers_where_first_provider_does_not_have_da
153
180
#[ tokio:: test( flavor = "multi_thread" ) ]
154
181
async fn if_there_is_two_static_providers_neither_having_data_is_invalid ( ) -> anyhow:: Result < ( ) > {
155
182
let resolver = ResolverTester :: new ( )
156
- . with_provider ( StaticProvider :: with_variable ( "foo" , Some ( "bar" ) ) )
157
- . with_provider ( StaticProvider :: with_variable ( "baz" , Some ( "hay" ) ) )
183
+ . with_provider ( StaticProvider :: with_variable (
184
+ "database_host" ,
185
+ Some ( "localhost" ) ,
186
+ ) )
187
+ . with_provider ( StaticProvider :: with_variable (
188
+ "api_key" ,
189
+ Some ( "super-secret-key" ) ,
190
+ ) )
158
191
. with_variable ( "hello" , None )
159
192
. make_resolver ( ) ?;
160
193
@@ -167,7 +200,7 @@ async fn if_there_is_two_static_providers_neither_having_data_is_invalid() -> an
167
200
async fn no_provider_data_available_but_variable_default_value_needed_is_invalid (
168
201
) -> anyhow:: Result < ( ) > {
169
202
let resolver = ResolverTester :: new ( )
170
- . with_variable ( "hello " , None )
203
+ . with_variable ( "api_key " , None )
171
204
. make_resolver ( ) ?;
172
205
173
206
assert ! ( resolver. ensure_required_variables_resolved( ) . await . is_err( ) ) ;
@@ -179,7 +212,7 @@ async fn no_provider_data_available_but_variable_default_value_needed_is_invalid
179
212
async fn no_provider_data_available_but_variable_has_default_value_needed_is_valid (
180
213
) -> anyhow:: Result < ( ) > {
181
214
let resolver = ResolverTester :: new ( )
182
- . with_variable ( "hello " , Some ( "World " ) )
215
+ . with_variable ( "api_key " , Some ( "super-secret-key " ) )
183
216
. make_resolver ( ) ?;
184
217
185
218
resolver. ensure_required_variables_resolved ( ) . await ?;
0 commit comments