Skip to content

Commit c2d7d1c

Browse files
committed
Adapt tests to the community edition
1 parent 1e8c282 commit c2d7d1c

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

tests/database_tests.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fn delete_file() {
4848
let tmp_dir = TempDir::new("cbl_rust").expect("create temp dir");
4949
let cfg = DatabaseConfiguration {
5050
directory: tmp_dir.path(),
51+
#[cfg(feature = "enterprise")]
5152
encryption_key: None,
5253
};
5354
if let Err(_) = Database::open(DB_NAME, Some(cfg)) {
@@ -70,6 +71,7 @@ fn copy_file() {
7071
let tmp_dir = TempDir::new("cbl_rust").expect("create temp dir");
7172
let cfg = DatabaseConfiguration {
7273
directory: tmp_dir.path(),
74+
#[cfg(feature = "enterprise")]
7375
encryption_key: None,
7476
};
7577
match Database::open(DB_NAME, Some(cfg.clone())) {
@@ -143,16 +145,19 @@ fn db_properties() {
143145
}
144146

145147
#[test]
148+
#[cfg(feature = "enterprise")]
146149
fn db_encryption_key() {
147150
let tmp_dir = TempDir::new("cbl_rust").expect("create temp dir");
148151
let cfg_no_encryption = DatabaseConfiguration {
149152
directory: tmp_dir.path(),
153+
#[cfg(feature = "enterprise")]
150154
encryption_key: None,
151155
};
152156
let encryption_key =
153157
EncryptionKey::new_from_password(EncryptionAlgorithm::None, "password1").unwrap();
154158
let cfg_encryption1 = DatabaseConfiguration {
155159
directory: tmp_dir.path(),
160+
#[cfg(feature = "enterprise")]
156161
encryption_key: Some(encryption_key.clone()),
157162
};
158163

tests/document_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ fn database_add_document_change_listener() {
234234
}
235235

236236
#[test]
237+
#[cfg(feature = "enterprise")]
237238
fn database_delete_document() {
238239
let (sender, receiver) = std::sync::mpsc::channel();
239240

tests/replicator_tests.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@
1717

1818
extern crate couchbase_lite;
1919

20+
#[cfg(feature = "enterprise")]
2021
use self::couchbase_lite::*;
22+
#[cfg(feature = "enterprise")]
2123
use encryptable::Encryptable;
24+
#[cfg(feature = "enterprise")]
2225
use std::{time::Duration, thread};
2326

2427
pub mod utils;
2528

2629
//////// TESTS:
2730

2831
#[test]
32+
#[cfg(feature = "enterprise")]
2933
fn push_replication() {
3034
let mut tester = utils::ReplicationTwoDbsTester::new(
3135
utils::ReplicationTestConfiguration::default(),
@@ -45,6 +49,7 @@ fn push_replication() {
4549
}
4650

4751
#[test]
52+
#[cfg(feature = "enterprise")]
4853
fn pull_replication() {
4954
let mut tester = utils::ReplicationTwoDbsTester::new(
5055
utils::ReplicationTestConfiguration::default(),
@@ -64,6 +69,7 @@ fn pull_replication() {
6469
}
6570

6671
#[test]
72+
#[cfg(feature = "enterprise")]
6773
fn push_pull_replication() {
6874
let mut tester = utils::ReplicationThreeDbsTester::new(
6975
utils::ReplicationTestConfiguration::default(),
@@ -91,6 +97,7 @@ fn push_pull_replication() {
9197
}
9298

9399
#[test]
100+
#[cfg(feature = "enterprise")]
94101
fn pull_type_not_pushing() {
95102
let config = utils::ReplicationTestConfiguration {
96103
replicator_type: ReplicatorType::Pull,
@@ -115,6 +122,7 @@ fn pull_type_not_pushing() {
115122
}
116123

117124
#[test]
125+
#[cfg(feature = "enterprise")]
118126
fn push_type_not_pulling() {
119127
let config = utils::ReplicationTestConfiguration {
120128
replicator_type: ReplicatorType::Push,
@@ -139,6 +147,7 @@ fn push_type_not_pulling() {
139147
}
140148

141149
#[test]
150+
#[cfg(feature = "enterprise")]
142151
fn document_ids() {
143152
let mut document_ids = MutableArray::new();
144153
document_ids.append().put_string("foo");
@@ -172,6 +181,7 @@ fn document_ids() {
172181
}
173182

174183
#[test]
184+
#[cfg(feature = "enterprise")]
175185
fn push_and_pull_filter() {
176186
let context1 = ReplicationConfigurationContext {
177187
push_filter: Some(Box::new(|document, _is_deleted, _is_access_removed| {
@@ -227,6 +237,7 @@ fn push_and_pull_filter() {
227237
}
228238

229239
#[test]
240+
#[cfg(feature = "enterprise")]
230241
fn conflict_resolver() {
231242
let (sender, receiver) = std::sync::mpsc::channel();
232243

@@ -316,6 +327,7 @@ fn conflict_resolver() {
316327
}
317328

318329
#[test]
330+
#[cfg(feature = "enterprise")]
319331
fn conflict_resolver_save_keep_local() {
320332
let mut tester = utils::ReplicationTwoDbsTester::new(
321333
utils::ReplicationTestConfiguration::default(),
@@ -397,6 +409,7 @@ fn conflict_resolver_save_keep_local() {
397409
}
398410

399411
#[test]
412+
#[cfg(feature = "enterprise")]
400413
fn conflict_resolver_save_keep_remote() {
401414
let mut tester = utils::ReplicationTwoDbsTester::new(
402415
utils::ReplicationTestConfiguration::default(),
@@ -479,6 +492,7 @@ fn conflict_resolver_save_keep_remote() {
479492

480493
// Encryption/Decryption
481494

495+
#[cfg(feature = "enterprise")]
482496
fn encryptor(
483497
_document_id: Option<String>,
484498
_properties: Dict,
@@ -490,6 +504,7 @@ fn encryptor(
490504
) -> std::result::Result<Vec<u8>, EncryptionError> {
491505
Ok(input.iter().map(|u| u ^ 48).collect())
492506
}
507+
#[cfg(feature = "enterprise")]
493508
fn decryptor(
494509
_document_id: Option<String>,
495510
_properties: Dict,
@@ -501,6 +516,7 @@ fn decryptor(
501516
) -> std::result::Result<Vec<u8>, EncryptionError> {
502517
Ok(input.iter().map(|u| u ^ 48).collect())
503518
}
519+
#[cfg(feature = "enterprise")]
504520
fn encryptor_err_temporary(
505521
_document_id: Option<String>,
506522
_properties: Dict,
@@ -512,6 +528,7 @@ fn encryptor_err_temporary(
512528
) -> std::result::Result<Vec<u8>, EncryptionError> {
513529
Err(EncryptionError::Temporary)
514530
}
531+
#[cfg(feature = "enterprise")]
515532
fn decryptor_err_temporary(
516533
_document_id: Option<String>,
517534
_properties: Dict,
@@ -523,6 +540,7 @@ fn decryptor_err_temporary(
523540
) -> std::result::Result<Vec<u8>, EncryptionError> {
524541
Err(EncryptionError::Temporary)
525542
}
543+
#[cfg(feature = "enterprise")]
526544
fn encryptor_err_permanent(
527545
_document_id: Option<String>,
528546
_properties: Dict,
@@ -534,6 +552,7 @@ fn encryptor_err_permanent(
534552
) -> std::result::Result<Vec<u8>, EncryptionError> {
535553
Err(EncryptionError::Permanent)
536554
}
555+
#[cfg(feature = "enterprise")]
537556
fn decryptor_err_permanent(
538557
_document_id: Option<String>,
539558
_properties: Dict,
@@ -547,6 +566,7 @@ fn decryptor_err_permanent(
547566
}
548567

549568
#[test]
569+
#[cfg(feature = "enterprise")]
550570
fn encryption_ok_decryption_ok() {
551571
let context1 = ReplicationConfigurationContext {
552572
default_collection_property_encryptor: Some(encryptor),
@@ -612,6 +632,7 @@ fn encryption_ok_decryption_ok() {
612632
}
613633

614634
#[test]
635+
#[cfg(feature = "enterprise")]
615636
fn encryption_error_temporary() {
616637
let config = utils::ReplicationTestConfiguration {
617638
continuous: false,
@@ -674,6 +695,7 @@ fn encryption_error_temporary() {
674695
}
675696

676697
#[test]
698+
#[cfg(feature = "enterprise")]
677699
fn decryption_error_temporary() {
678700
let config = utils::ReplicationTestConfiguration {
679701
continuous: false,
@@ -736,6 +758,7 @@ fn decryption_error_temporary() {
736758
}
737759

738760
#[test]
761+
#[cfg(feature = "enterprise")]
739762
fn encryption_error_permanent() {
740763
let config = utils::ReplicationTestConfiguration {
741764
continuous: false,
@@ -818,6 +841,7 @@ fn encryption_error_permanent() {
818841
}
819842

820843
#[test]
844+
#[cfg(feature = "enterprise")]
821845
fn decryption_error_permanent() {
822846
let config = utils::ReplicationTestConfiguration {
823847
continuous: false,
@@ -904,6 +928,7 @@ mod unsafe_test {
904928
use super::*;
905929

906930
#[test]
931+
#[cfg(feature = "enterprise")]
907932
fn continuous() {
908933
let config = utils::ReplicationTestConfiguration {
909934
continuous: false,

tests/utils.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use self::couchbase_lite::*;
55
use self::tempdir::TempDir;
66

77
use std::{
8-
collections::HashMap,
98
sync::{Arc, Mutex, MutexGuard},
109
thread, time,
1110
};
11+
#[cfg(feature = "enterprise")]
12+
use std::collections::HashMap;
1213

1314
// Enables check for leaks of native CBL objects after `with_db()` finishes.
1415
// WARNING: These checks only work if one test method runs at a time, i.e. testing is single
@@ -46,6 +47,7 @@ where
4647
let tmp_dir = TempDir::new("cbl_rust").expect("create temp dir");
4748
let cfg = DatabaseConfiguration {
4849
directory: tmp_dir.path(),
50+
#[cfg(feature = "enterprise")]
4951
encryption_key: None,
5052
};
5153
let mut db = Database::open(DB_NAME, Some(cfg)).expect("open db");
@@ -90,6 +92,7 @@ impl Default for ReplicationTestConfiguration {
9092
}
9193
}
9294

95+
#[cfg(feature = "enterprise")]
9396
fn generate_replication_configuration(
9497
local_db: &Database,
9598
central_db: &Database,
@@ -116,6 +119,7 @@ fn generate_replication_configuration(
116119
}
117120
}
118121

122+
#[cfg(feature = "enterprise")]
119123
pub struct ReplicationTwoDbsTester {
120124
_tmp_dir: TempDir,
121125
pub local_database: Database,
@@ -124,6 +128,7 @@ pub struct ReplicationTwoDbsTester {
124128
replicator_continuous: bool,
125129
}
126130

131+
#[cfg(feature = "enterprise")]
127132
impl ReplicationTwoDbsTester {
128133
pub fn new(
129134
replication_configuration: ReplicationTestConfiguration,
@@ -227,6 +232,7 @@ impl ReplicationTwoDbsTester {
227232
}
228233
}
229234

235+
#[cfg(feature = "enterprise")]
230236
impl Drop for ReplicationTwoDbsTester {
231237
fn drop(&mut self) {
232238
self.stop_replicator();
@@ -236,6 +242,7 @@ impl Drop for ReplicationTwoDbsTester {
236242
}
237243
}
238244

245+
#[cfg(feature = "enterprise")]
239246
pub struct ReplicationThreeDbsTester {
240247
_tmp_dir: TempDir,
241248
local_database_1: Database,
@@ -247,6 +254,7 @@ pub struct ReplicationThreeDbsTester {
247254
replicator_2_continuous: bool,
248255
}
249256

257+
#[cfg(feature = "enterprise")]
250258
impl ReplicationThreeDbsTester {
251259
pub fn new(
252260
replication_configuration_1: ReplicationTestConfiguration,
@@ -408,6 +416,7 @@ impl ReplicationThreeDbsTester {
408416
}
409417
}
410418

419+
#[cfg(feature = "enterprise")]
411420
impl Drop for ReplicationThreeDbsTester {
412421
fn drop(&mut self) {
413422
self.stop_replicators();

0 commit comments

Comments
 (0)