Skip to content

Commit 1c1af7a

Browse files
committed
chore: retrieve cargo target dir
1 parent b109ab8 commit 1c1af7a

File tree

3 files changed

+11
-65
lines changed

3 files changed

+11
-65
lines changed

.github/workflows/upload-artifacts.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

test/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#[cfg(test)]
22
mod smoke;
33

4-
use std::{str::FromStr, time::Duration};
4+
use std::{env::var, str::FromStr, time::Duration};
55

66
use anyhow::Result;
77
use reqwest::{Method, Url};
88
use wait_on::{WaitOptions, Waitable, resource::http::HttpWaiter};
99

10-
pub const HTTP_SERVER_RELEASE_BINARY: &str = "../target/release/http-server";
10+
pub fn release_binary_path() -> Result<String> {
11+
let path = var("CARGO_TARGET_DIR")?;
12+
Ok(format!("{path}/release/http-server"))
13+
}
1114

1215
pub async fn wait_on_http_server(port: u16) -> Result<()> {
1316
let url = Url::from_str(&format!("http://127.0.0.1:{port}"))?;

test/src/smoke.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use anyhow::{Context, Result};
22
use reqwest::get;
33
use xprocess::Process;
44

5-
use crate::{HTTP_SERVER_RELEASE_BINARY, wait_on_http_server};
5+
use crate::{release_binary_path, wait_on_http_server};
66

77
#[tokio::test]
88
async fn runs_without_panicking() -> Result<()> {
9-
let http_server = Process::spawn_with_args(HTTP_SERVER_RELEASE_BINARY, ["start"])?;
9+
let http_server = Process::spawn_with_args(release_binary_path()?, ["start".into()])?;
1010
wait_on_http_server(7878).await?;
1111
http_server.kill()?;
1212

@@ -15,8 +15,10 @@ async fn runs_without_panicking() -> Result<()> {
1515

1616
#[tokio::test]
1717
async fn returns_json_from_api_index() -> Result<()> {
18-
let http_server =
19-
Process::spawn_with_args(HTTP_SERVER_RELEASE_BINARY, ["start", "--port", "7879"])?;
18+
let http_server = Process::spawn_with_args(
19+
release_binary_path()?,
20+
["start".into(), "--port".into(), "7879".into()],
21+
)?;
2022
wait_on_http_server(7879).await?;
2123

2224
let res = get("http://127.0.0.1:7879/api/v1")

0 commit comments

Comments
 (0)