-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding mock support for the Database trait in AKD #333
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor suggestions, but looks fine otherwise! Thanks for getting this up, @slawlor!
impl<Db: Database> Clone for StorageManager<Db> { | ||
fn clone(&self) -> Self { | ||
Self { | ||
cache: self.cache.clone(), | ||
transaction: self.transaction.clone(), | ||
db: self.db.clone(), | ||
metrics: self.metrics.clone(), | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just derive Clone instead?
let mut updates = vec![]; | ||
for i in 0..1 { | ||
updates.push(( | ||
AkdLabel(format!("hello1{}", i).as_bytes().to_vec()), | ||
AkdValue(format!("hello1{}", i).as_bytes().to_vec()), | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: I think this can be written out as
let updates = (0..1).map(|i| (AkdLabel(...), AkdVaue(...))).collect();
for i in 0..1 { | ||
updates.push(( | ||
AkdLabel(format!("hello1{}", i).as_bytes().to_vec()), | ||
AkdValue(format!("hello1{}", i + 1).as_bytes().to_vec()), | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't recall off-hand if we have any AKD user code that creates multiple StorageManager
s with the same database struct. If we do, we might run into issues because:
- the database trait no longer inherits
Clone
- there's no means of creating a
StorageManager
by passing in anArc
of a DB.
Either ways we can address the issue if we run into it - thanks for adding mocking so quickly @slawlor !
Related to: #332
Tests to come