Add REST APIs for getting and adding contributors
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
5b906e731d
commit
1981de4cae
12 changed files with 206 additions and 56 deletions
37
crates/collab/src/db/tests/contributor_tests.rs
Normal file
37
crates/collab/src/db/tests/contributor_tests.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
use super::Database;
|
||||
use crate::{db::NewUserParams, test_both_dbs};
|
||||
use std::sync::Arc;
|
||||
|
||||
test_both_dbs!(
|
||||
test_contributors,
|
||||
test_contributors_postgres,
|
||||
test_contributors_sqlite
|
||||
);
|
||||
|
||||
async fn test_contributors(db: &Arc<Database>) {
|
||||
db.create_user(
|
||||
&format!("user1@example.com"),
|
||||
false,
|
||||
NewUserParams {
|
||||
github_login: format!("user1"),
|
||||
github_user_id: 1,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.user_id;
|
||||
|
||||
assert_eq!(db.get_contributors().await.unwrap(), Vec::<String>::new());
|
||||
|
||||
db.add_contributor("user1", 1, None).await.unwrap();
|
||||
assert_eq!(
|
||||
db.get_contributors().await.unwrap(),
|
||||
vec!["user1".to_string()]
|
||||
);
|
||||
|
||||
db.add_contributor("user2", 2, None).await.unwrap();
|
||||
assert_eq!(
|
||||
db.get_contributors().await.unwrap(),
|
||||
vec!["user1".to_string(), "user2".to_string()]
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue