@@ -14,10 +14,10 @@ pub enum FileStore {
14
14
15
15
#[ derive( Clone , Debug , PartialEq ) ]
16
16
pub struct S3Config {
17
- bucket : String ,
18
- path : String ,
19
- endpoint : Option < String > ,
20
- region : Option < String > ,
17
+ pub bucket : String ,
18
+ pub path : String ,
19
+ pub endpoint : Option < String > ,
20
+ pub region : Option < String > ,
21
21
}
22
22
23
23
#[ derive( Clone , Debug , PartialEq ) ]
@@ -172,63 +172,3 @@ pub async fn get_s3_signed_url(
172
172
173
173
Ok ( uri)
174
174
}
175
-
176
- #[ cfg( test) ]
177
- mod test {
178
- use super :: * ;
179
-
180
- use crate :: config:: { self , Opts } ;
181
-
182
- #[ actix_rt:: test]
183
- async fn file_store_tests ( ) {
184
- let unique_string = atomic_lib:: utils:: random_string ( 10 ) ;
185
- use clap:: Parser ;
186
- let mut opts = Opts :: parse_from ( [
187
- "atomic-server" ,
188
- "--initialize" ,
189
- "--data-dir" ,
190
- & format ! ( "./.temp/{}/db" , unique_string) ,
191
- "--config-dir" ,
192
- & format ! ( "./.temp/{}/config" , unique_string) ,
193
- ] ) ;
194
-
195
- let mut config = config:: build_config ( opts. clone ( ) )
196
- . map_err ( |e| format ! ( "Initialization failed: {}" , e) )
197
- . expect ( "failed init config" ) ;
198
-
199
- let fs_store = FileStore :: init_fs_from_config ( & config) ;
200
- if let FileStore :: FS ( fs_config) = & fs_store {
201
- assert ! ( fs_config. path. to_str( ) . unwrap( ) . contains( "uploads" ) ) ;
202
- } else {
203
- panic ! ( "fs FileStore not initiated" ) ;
204
- }
205
- let store = FileStore :: init_from_config ( & config, fs_store. clone ( ) ) ;
206
- assert_eq ! ( fs_store, store) ;
207
- assert_eq ! ( "fs:" , fs_store. prefix( ) ) ;
208
- assert_eq ! ( "fs%3A" , fs_store. encoded( ) ) ;
209
-
210
- assert ! ( fs_store. get_fs_file_path( "my-great-file" ) . unwrap( ) . to_str( ) . unwrap( ) . contains( "uploads/my-great-file" ) ) ;
211
- assert ! ( fs_store. get_fs_file_path( "fs:my-great-file" ) . unwrap( ) . to_str( ) . unwrap( ) . contains( "uploads/my-great-file" ) ) ;
212
-
213
- // FileStore::S3 init
214
- opts. s3_bucket = Some ( "test-bucket" . to_string ( ) ) ;
215
- opts. s3_path = Some ( "uploads" . to_string ( ) ) ;
216
- config. opts = opts;
217
- let appstate = crate :: appstate:: init ( config. clone ( ) ) . expect ( "failed init appstate" ) ;
218
-
219
- let s3_store = FileStore :: init_from_config ( & config, fs_store. clone ( ) ) ;
220
- if let FileStore :: S3 ( s3_config) = & s3_store {
221
- assert_eq ! ( s3_config. bucket, "test-bucket" ) ;
222
- assert_eq ! ( s3_config. path, "uploads" ) ;
223
- } else {
224
- panic ! ( "s3 FileStore not initiated" ) ;
225
- }
226
-
227
- assert_eq ! ( "s3:" , s3_store. prefix( ) ) ;
228
- assert_eq ! ( "s3%3A" , s3_store. encoded( ) ) ;
229
-
230
- assert_eq ! ( & fs_store, FileStore :: get_subject_file_store( & appstate, "my-great-file" ) ) ;
231
- assert_eq ! ( & fs_store, FileStore :: get_subject_file_store( & appstate, "fs:my-great-file" ) ) ;
232
- assert_eq ! ( & s3_store, FileStore :: get_subject_file_store( & appstate, "s3:my-great-file" ) ) ;
233
- }
234
- }
0 commit comments