Skip to content
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

Merged
merged 5 commits into from
Jan 4, 2023

Conversation

slawlor
Copy link
Contributor

@slawlor slawlor commented Jan 3, 2023

Related to: #332

Tests to come

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 3, 2023
akd/src/tests.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@dillonrg dillonrg left a 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!

akd/src/tests.rs Show resolved Hide resolved
@slawlor slawlor marked this pull request as ready for review January 4, 2023 03:20
@slawlor slawlor merged commit 7bb93b7 into facebook:main Jan 4, 2023
@slawlor slawlor deleted the mocks branch January 4, 2023 04:01
Comment on lines +63 to +73
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(),
}
}
}

Copy link
Contributor

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?

Comment on lines +1186 to +1192
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()),
));
}
Copy link
Contributor

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();

Comment on lines +1215 to +1220
for i in 0..1 {
updates.push((
AkdLabel(format!("hello1{}", i).as_bytes().to_vec()),
AkdValue(format!("hello1{}", i + 1).as_bytes().to_vec()),
));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Member

@afterdusk afterdusk left a 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 StorageManagers with the same database struct. If we do, we might run into issues because:

  1. the database trait no longer inherits Clone
  2. there's no means of creating a StorageManager by passing in an Arc of a DB.

Either ways we can address the issue if we run into it - thanks for adding mocking so quickly @slawlor !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants