forked from TabbyML/tabby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract RepositoryAccess to abstract out scheduler reading …
…(from config / database) (TabbyML#1388) * hide all enterprise commands * refactor(scheduler): extract RepositoryAccess for scheduler * ensure community build always success * remove scheduler related code
- Loading branch information
Showing
19 changed files
with
155 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub static USER_HEADER_FIELD_NAME: &str = "x-tabby-user"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
use async_trait::async_trait; | ||
use tabby_common::config::{RepositoryAccess, RepositoryConfig}; | ||
|
||
struct StaticRepositoryAccess { | ||
repositories: Vec<RepositoryConfig>, | ||
} | ||
|
||
#[async_trait] | ||
impl RepositoryAccess for StaticRepositoryAccess { | ||
async fn list_repositories(&self) -> anyhow::Result<Vec<RepositoryConfig>> { | ||
Ok(self.repositories.clone()) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::fs::create_dir_all; | ||
|
||
use tabby_common::{ | ||
config::{Config, RepositoryConfig, ServerConfig}, | ||
path::set_tabby_root, | ||
}; | ||
use tabby_common::{config::RepositoryConfig, path::set_tabby_root}; | ||
use temp_testdir::*; | ||
use tracing_test::traced_test; | ||
|
||
use super::StaticRepositoryAccess; | ||
|
||
#[traced_test] | ||
#[tokio::test] | ||
async fn end_to_end() { | ||
let root = TempDir::default(); | ||
create_dir_all(&root).expect("Failed to create tabby root"); | ||
set_tabby_root(root.to_path_buf()); | ||
|
||
let config = Config { | ||
let config = StaticRepositoryAccess { | ||
repositories: vec![RepositoryConfig::new( | ||
"https://github.com/TabbyML/interview-questions".to_owned(), | ||
)], | ||
server: ServerConfig::default(), | ||
}; | ||
|
||
let res = tabby_scheduler::scheduler(true, config.repositories).await; | ||
let res = tabby_scheduler::scheduler(true, config).await; | ||
res.expect("Failed to run scheduler"); | ||
} | ||
} |
Oops, something went wrong.