Skip to content

Commit

Permalink
saving result file for easy compare in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
vctqs1 committed Apr 21, 2024
1 parent a1aab35 commit ba4720f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/web/dist
/web/node_modules
/web/wasm

tests/fixtures/*.oas.json
31 changes: 26 additions & 5 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
use std::fs::File;
use std::io::prelude::*;


macro_rules! test_fixture {
($name:ident, $filename:expr) => {
#[test]
fn $name() {
let filename = get_fixture($filename);
let options = postman2openapi::TranspileOptions {
format: postman2openapi::TargetFormat::Json,
};
let options = postman2openapi::TranspileOptions {
format: postman2openapi::TargetFormat::Json,
};
match postman2openapi::from_path(&filename, options) {
Ok(_oas) => assert!(true),
Err(err) => assert!(false, "{:?}", err),
Ok(_oas) => {
// Specify the target file path convert filename to filename_oas.json
let file_path = filename.replace("postman.json", "oas.json");

// Remove file if it exists
std::fs::remove_file(file_path.clone()).unwrap_or_default();

// Open or create the file
let mut file = File::create(file_path).expect("Failed to create file");

// Write data to the file
match file.write_all(_oas.as_bytes()) {
Ok(_) => assert!(true),
Err(err) => assert!(false, "{:?}", err),
}
},
Err(err) => {
assert!(false, "{:?}", err);
},
}
}
};
Expand Down

0 comments on commit ba4720f

Please sign in to comment.