Skip to content

Commit

Permalink
add test for json file reading
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Dec 2, 2024
1 parent 2908d89 commit a934d60
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::{
fs,
path::{Path, PathBuf},
};

pub fn setup() {
// some setup code, like creating required files/directories, starting
// servers, etc.
let crate_dir = PathBuf::new().join(env!("CARGO_MANIFEST_DIR"));
let tests_dir = crate_dir.join("tests");
let samples_dir = tests_dir.join("samples");
}

pub fn get_samples_dir() -> String {
let crate_dir = PathBuf::new().join(env!("CARGO_MANIFEST_DIR"));
let tests_dir = crate_dir.join("tests");
tests_dir.join("samples").to_string_lossy().to_string()
}
File renamed without changes.
File renamed without changes.
12 changes: 11 additions & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use hmm_rs::commands::*;
use std::path::{Path, PathBuf};

use hmm_rs::{commands::*, hmm};
mod common;

#[test]
fn test_create_and_clean_haxelib_folder() {
Expand All @@ -7,3 +10,10 @@ fn test_create_and_clean_haxelib_folder() {
assert!(init_command::create_haxelib_folder().is_err());
assert!(clean_command::remove_haxelib_folder().is_ok());
}

#[test]
fn test_hmm_json_read() {
// common::setup();
let flixel_json = format!("{}/flixel.json", common::get_samples_dir());
assert!(hmm::json::read_json(flixel_json.as_str()).is_ok());
}

0 comments on commit a934d60

Please sign in to comment.