Skip to content

Commit

Permalink
use async-rs/async-std#768 for fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheng JIANG committed May 9, 2020
1 parent 76045f9 commit 0385d58
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ip_network = { version = "0.3.4", optional = true }
ttl_cache = { version = "0.5.1", optional = true }
lazy_static = "1.4.0"
indexmap = "1.3.1"
async-std = { version = "1.6.0-beta.1", optional = true }
async-std = { git = "https://github.com/async-rs/async-std", branch = "fix/file-block", optional = true }
async-trait = "0.1.24"
log = { version = "0.4.8", optional = true }
tokio = { version = "0.2.11", optional = true, default-features = false }
Expand All @@ -41,5 +41,5 @@ watcher = []
opt-level = 0

[dev-dependencies]
async-std = { version = "1.6.0-beta.1", features = [ "attributes" ] }
async-std = { git = "https://github.com/async-rs/async-std", branch = "fix/file-block", features = [ "attributes" ] }
tokio = { version = "0.2.11", features = [ "full" ] }
8 changes: 8 additions & 0 deletions src/cache/default_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ mod tests {
use super::*;
use std::thread::sleep;

#[cfg(feature = "cached")]
#[test]
fn test_set_and_get() {
let mut cache = DefaultCache::new(1);

cache.set(vec!["alice", "/data1", "read"], false);
assert!(cache.get(&vec!["alice", "/data1", "read"]) == Some(&false));
}

#[cfg(feature = "cached")]
#[test]
fn test_set_ttl() {
let mut cache = DefaultCache::new(1);
cache.set_ttl(Duration::from_secs(2));
Expand All @@ -84,6 +88,8 @@ mod tests {
assert!(!cache.has(&vec!["alice", "/data1", "read"]));
}

#[cfg(feature = "cached")]
#[test]
fn test_capacity() {
let mut cache = DefaultCache::new(1);

Expand All @@ -93,6 +99,8 @@ mod tests {
assert!(cache.has(&vec!["bob", "/data2", "write"]));
}

#[cfg(feature = "cached")]
#[test]
fn test_set_capacity() {
let mut cache = DefaultCache::new(1);
cache.set_capacity(2);
Expand Down
2 changes: 1 addition & 1 deletion src/emitter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(feature = "watcher")]
#[cfg(any(feature = "watcher", feature = "cached"))]
use crate::core_api::CoreApi;

#[cfg(feature = "cached")]
Expand Down
1 change: 1 addition & 0 deletions src/enforcer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ mod tests {
);
}

#[cfg(feature = "ip")]
#[cfg_attr(feature = "runtime-async-std", async_std::test)]
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
async fn test_ip_match_model() {
Expand Down
2 changes: 1 addition & 1 deletion src/internal_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
Result,
};

#[cfg(feature = "watcher")]
#[cfg(any(feature = "watcher", feature = "cached"))]
use crate::emitter::EventData;

#[cfg(feature = "cached")]
Expand Down

0 comments on commit 0385d58

Please sign in to comment.