use std::env;
use onetaskgraph_live::{Exclusivity, Session};
#[allow(dead_code)]
mod journey;
mod lane;
use lane::{LiveLane, SESSION_NAME, live_lane};
#[tokio::test]
async fn real_projects_v2_contract_writes_and_leaves_no_residue() {
let lane = live_lane(
env::var("GH_PROJECTS_TOKEN").ok().as_deref(),
env::var("GH_PROJECTS_OWNER").ok().as_deref(),
env::var("GH_PROJECTS_NUMBER").ok().as_deref(),
env::var("GH_PROJECTS_REPOSITORY").ok().as_deref(),
env::var(onetaskgraph_live::REQUIRED_VARIABLE)
.ok()
.as_deref(),
)
.unwrap_or_else(|error| panic!("the GitHub Projects live lane cannot run: {error}"));
let (token, owner, project_number, repository) = match lane {
LiveLane::Run {
token,
owner,
project_number,
repository,
} => (token, owner, project_number, repository),
LiveLane::Skip(reason) => {
journey::say(&format!("skipped live GitHub Projects journey: {reason}"));
return;
}
};
let session = Session::open(SESSION_NAME, token, Exclusivity::Shared)
.unwrap_or_else(|declined| declined.refuse());
journey::against(journey::Endpoints::github());
journey::run(journey::Nomination {
token: session.credential().expose().to_owned(),
owner,
project_number,
repository,
})
.await;
}