Add observability using the tracing crate
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
pub mod test_helper;
|
||||
|
||||
#[actix_rt::test]
|
||||
#[tokio::test]
|
||||
async fn health_check_works() {
|
||||
let address = test_helper::spawn_app();
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
@@ -3,14 +3,14 @@ pub mod test_helper;
|
||||
use contextswitch_api::taskwarrior;
|
||||
use contextswitch_types::Task;
|
||||
|
||||
#[actix_rt::test]
|
||||
#[tokio::test]
|
||||
async fn list_tasks() {
|
||||
let task_data_path = test_helper::setup_tasks();
|
||||
let address = test_helper::spawn_app();
|
||||
let client = reqwest::Client::new();
|
||||
taskwarrior::add(vec!["test1", "contextswitch:'{\"test\": 1}'"]).unwrap();
|
||||
|
||||
let response = client
|
||||
let response: reqwest::Response = client
|
||||
.get(&format!("{}/tasks?filter=ls", &address))
|
||||
.send()
|
||||
.await
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
use contextswitch_api::observability::{get_subscriber, init_subscriber};
|
||||
use contextswitch_api::taskwarrior;
|
||||
use mktemp::Temp;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::fs;
|
||||
use std::net::TcpListener;
|
||||
|
||||
static TRACING: Lazy<()> = Lazy::new(|| {
|
||||
let subscriber = get_subscriber("info".to_string());
|
||||
init_subscriber(subscriber);
|
||||
});
|
||||
|
||||
pub fn spawn_app() -> String {
|
||||
Lazy::force(&TRACING);
|
||||
|
||||
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user