@@ -6,3 +6,40 @@ mod thread_local;
66
77pub use cache_impl:: Cache ;
88pub use cached_path:: CachedPath ;
9+
10+ #[ cfg( test) ]
11+ mod tests {
12+ use super :: borrowed_path:: BorrowedCachedPath ;
13+ use super :: cache_impl:: Cache ;
14+ use crate :: FileSystem ;
15+ use std:: path:: Path ;
16+
17+ #[ test]
18+ fn test_borrowed_cached_path_eq ( ) {
19+ let path1 = Path :: new ( "/foo/bar" ) ;
20+ let path2 = Path :: new ( "/foo/bar" ) ;
21+ let path3 = Path :: new ( "/foo/baz" ) ;
22+
23+ let borrowed1 = BorrowedCachedPath { hash : 1 , path : path1 } ;
24+ let borrowed2 = BorrowedCachedPath { hash : 2 , path : path2 } ;
25+ let borrowed3 = BorrowedCachedPath { hash : 1 , path : path3 } ;
26+
27+ // Same path should be equal even with different hash
28+ assert_eq ! ( borrowed1, borrowed2) ;
29+ // Different path should not be equal even with same hash
30+ assert_ne ! ( borrowed1, borrowed3) ;
31+ }
32+
33+ #[ test]
34+ fn test_cached_path_debug ( ) {
35+ #[ cfg( feature = "yarn_pnp" ) ]
36+ let cache = Cache :: new ( crate :: FileSystemOs :: new ( false ) ) ;
37+ #[ cfg( not( feature = "yarn_pnp" ) ) ]
38+ let cache = Cache :: new ( crate :: FileSystemOs :: new ( ) ) ;
39+
40+ let path = cache. value ( Path :: new ( "/foo/bar" ) ) ;
41+ let debug_str = format ! ( "{path:?}" ) ;
42+ assert ! ( debug_str. contains( "FsCachedPath" ) ) ;
43+ assert ! ( debug_str. contains( "path" ) ) ;
44+ }
45+ }
0 commit comments