Skip to content

Commit a6d069e

Browse files
committed
finish refactoring paginated_files test
1 parent fc628c5 commit a6d069e

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

cpp-linter/tests/paginated_changed_files.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ use mockito::Matcher;
77
use tempfile::{NamedTempFile, TempDir};
88

99
use cpp_linter::{logger, rest_client::RestClient};
10-
use std::{
11-
env,
12-
io::Write,
13-
path::{Path, PathBuf},
14-
};
10+
use std::{env, io::Write, path::Path};
1511

1612
#[derive(PartialEq, Default)]
1713
enum EventType {
@@ -36,9 +32,8 @@ const RESET_RATE_LIMIT_HEADER: &str = "x-ratelimit-reset";
3632
const REMAINING_RATE_LIMIT_HEADER: &str = "x-ratelimit-remaining";
3733
const MALFORMED_RESPONSE_PAYLOAD: &str = "{\"message\":\"Resource not accessible by integration\"}";
3834

39-
async fn get_paginated_changes(lib_root: &Path, _tmp_dir: &TempDir, test_params: &TestParams) {
40-
let tmp = TempDir::new().expect("Failed to create a temp dir for test");
41-
let mut event_payload = NamedTempFile::new_in(tmp.path())
35+
async fn get_paginated_changes(lib_root: &Path, tmp_dir: &TempDir, test_params: &TestParams) {
36+
let mut event_payload = NamedTempFile::new_in(tmp_dir.path())
4237
.expect("Failed to spawn a tmp file for test event payload");
4338
unsafe {
4439
env::set_var("GITHUB_ACTIONS", "true");
@@ -88,7 +83,6 @@ async fn get_paginated_changes(lib_root: &Path, _tmp_dir: &TempDir, test_params:
8883
unsafe {
8984
env::set_var("GITHUB_API_URL", server.url());
9085
}
91-
env::set_current_dir(tmp.path()).unwrap();
9286
logger::try_init();
9387
log::set_max_level(log::LevelFilter::Debug);
9488
let gh_client = RestClient::new();
@@ -149,7 +143,7 @@ async fn get_paginated_changes(lib_root: &Path, _tmp_dir: &TempDir, test_params:
149143
&LinesChangedOnly::Off,
150144
&None::<String>,
151145
false,
152-
&PathBuf::from("."),
146+
tmp_dir.path(),
153147
)
154148
.await;
155149
match files {

0 commit comments

Comments
 (0)