GitHub user thekatze edited a discussion: When writing files to the InMemory 
store, can I control the last_modified date for unit testing?

I’m developing a service that compacts Parquet files in cloud storage and use 
the `InMemory` store for end-to-end testing. It works well for validating state 
after writes, but it currently lacks the ability to control or mock the 
`last_modified` timestamp of stored objects.

Currently, `put` in the [`InMemory` store 
implementation](https://github.com/apache/arrow-rs-object-store/blob/cb85a6133f31fd2fc0a22d8809f239d398af4916/src/memory.rs#L209)
 always sets `last_modified` using `Utc::now()`, with no clear way to override 
it.

Is there an existing mechanism to override this behavior that I missed?
If not, should we introduce a time provider API? For example:

```rust
let mock_time = Arc::new(MockTimeProvider::new(Utc::now()));
let store = InMemory::new().with_time_provider(mock_time.clone());

store.put();
mock_time.advance(TimeDelta::hours(1));
store.put();
```

[Proof of concept 
gist](https://gist.github.com/thekatze/a8515a8094779ab8198b284022f406dd)

This would enable tests that depend on time-based logic, such as verifying 
lockfile expiration or deleting files older than a certain age.

If this approach is acceptable, I’m willing to open a PR implementing it.

GitHub link: https://github.com/apache/arrow-rs-object-store/discussions/533

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to