Skip to content

Commit

Permalink
Use github workspace or current directory for data path
Browse files Browse the repository at this point in the history
  • Loading branch information
MGibson1 committed Sep 19, 2024
1 parent d4e04d9 commit c926213
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions languages/language_tests/src/e2e_data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fs::File, io::BufReader};
use std::{env::var, fs::File, io::BufReader, path::Path};

use anyhow::{Context, Result};
use bitwarden::secrets_manager::projects::ProjectResponse;
Expand Down Expand Up @@ -93,8 +93,14 @@ pub fn load_realized_secrets(
}

fn load_data() -> Result<E2EData> {
// Get working directory
let data_path = var("GITHUB_WORKSPACE")
.map(|p| Path::new(&p).join("languages").join("language-tests"))
.or_else(|_| var("PWD").map(|p| Path::new(&p).to_path_buf()))
.context("Failed to get current directory")?
.join("e2e_data.json");

Check warning on line 101 in languages/language_tests/src/e2e_data.rs

View check run for this annotation

Codecov / codecov/patch

languages/language_tests/src/e2e_data.rs#L97-L101

Added lines #L97 - L101 were not covered by tests
// read e2e data from file
let file = File::open("e2e_data.json").context("Failed to open e2e data file")?;
let file = File::open(data_path).context("Failed to open e2e data file")?;

Check warning on line 103 in languages/language_tests/src/e2e_data.rs

View check run for this annotation

Codecov / codecov/patch

languages/language_tests/src/e2e_data.rs#L103

Added line #L103 was not covered by tests
let reader = BufReader::new(file);

let data: E2EData = serde_json::from_reader(reader).context("Failed to parse e2e data")?;
Expand Down

0 comments on commit c926213

Please sign in to comment.