Skip to content

Commit

Permalink
Check error message for read-only mode test
Browse files Browse the repository at this point in the history
  • Loading branch information
uellenberg committed Jan 26, 2024
1 parent c765ec1 commit 6364e35
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,10 @@ mod test {
.unwrap();

// Use disk cache.
let mut config = Config { cache: None, ..Default::default() };
let mut config = Config {
cache: None,
..Default::default()
};

let tempdir = tempfile::Builder::new()
.prefix("sccache_test_rust_cargo")
Expand All @@ -707,10 +710,7 @@ mod test {
let cache = storage_from_config(&config, runtime.handle()).unwrap();

runtime.block_on(async move {
cache
.put("test1", CacheWrite::default())
.await
.unwrap();
cache.put("test1", CacheWrite::default()).await.unwrap();
cache
.put_preprocessor_cache_entry("test1", PreprocessorCacheEntry::default())
.unwrap();
Expand All @@ -724,13 +724,21 @@ mod test {
let cache = storage_from_config(&config, runtime.handle()).unwrap();

runtime.block_on(async move {
cache
.put("test1", CacheWrite::default())
.await
.unwrap_err();
cache
.put_preprocessor_cache_entry("test1", PreprocessorCacheEntry::default())
.unwrap_err();
assert_eq!(
cache
.put("test1", CacheWrite::default())
.await
.unwrap_err()
.to_string(),
"Cannot write to a read-only cache"
);
assert_eq!(
cache
.put_preprocessor_cache_entry("test1", PreprocessorCacheEntry::default())
.unwrap_err()
.to_string(),
"Cannot write to a read-only cache"
);
});
}
}
Expand Down

0 comments on commit 6364e35

Please sign in to comment.