Add new task endpoint
This commit is contained in:
@@ -10,23 +10,31 @@ static TRACING: Lazy<()> = Lazy::new(|| {
|
||||
init_subscriber(subscriber);
|
||||
});
|
||||
|
||||
pub fn spawn_app() -> String {
|
||||
Lazy::force(&TRACING);
|
||||
|
||||
static SERVER_ADDRESS: Lazy<String> = Lazy::new(|| {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
|
||||
let server = contextswitch_api::run(listener).expect("Failed to bind address");
|
||||
let _ = tokio::spawn(server);
|
||||
format!("http://127.0.0.1:{}", port)
|
||||
}
|
||||
});
|
||||
|
||||
pub fn setup_tasks() -> String {
|
||||
static TASK_DATA_LOCATION: Lazy<String> = Lazy::new(|| {
|
||||
let tmp_dir = Temp::new_dir().unwrap();
|
||||
let task_data_location = taskwarrior::load_config(tmp_dir.to_str());
|
||||
tmp_dir.release();
|
||||
|
||||
return task_data_location;
|
||||
task_data_location
|
||||
});
|
||||
|
||||
pub fn spawn_app() -> String {
|
||||
Lazy::force(&TRACING);
|
||||
setup_tasks();
|
||||
Lazy::force(&SERVER_ADDRESS).to_string()
|
||||
}
|
||||
|
||||
pub fn setup_tasks() -> String {
|
||||
Lazy::force(&TASK_DATA_LOCATION).to_string()
|
||||
}
|
||||
|
||||
pub fn clear_tasks(task_data_location: String) {
|
||||
|
||||
Reference in New Issue
Block a user