Skip to content

Commit

Permalink
chore: don't use tests when not on actual system
Browse files Browse the repository at this point in the history
  • Loading branch information
DashieTM committed Sep 23, 2023
1 parent 7932431 commit 6fe0fe8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/monitors/hypr_monitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ pub fn get_current_monitor_hash(name: Option<&String>) -> String {

pub fn save_hypr_monitor_data(path: String, name: Option<&String>, hash: Option<String>) {
let monitor_hash = hash.unwrap_or(get_current_monitor_hash(name));
let mut file = File::create(path + "monitor_configs/" + &monitor_hash + ".json").expect("Could not open json file");
let mut file = File::create(path + "monitor_configs/" + &monitor_hash + ".json")
.expect("Could not open json file");
file.write_all(&get_hypr_monitor_info())
.expect("Could not write to file");
}

pub fn import_hypr_data(path: String, name: Option<&String>, hash: Option<String>) -> Vec<Monitor> {
use std::io::prelude::*;
let monitor_hash = hash.unwrap_or(get_current_monitor_hash(name));
let mut file = File::open(path + "monitor_configs/" + &monitor_hash + ".json").expect("Could not read file");
let mut file = File::open(path + "monitor_configs/" + &monitor_hash + ".json")
.expect("Could not read file");
let mut contents = String::new();
file.read_to_string(&mut contents)
.expect("Could not read data from file");
Expand Down Expand Up @@ -133,7 +135,11 @@ pub fn set_hypr_monitors_from_file(path: String, name: Option<&String>, hash: Op
fn import_data_test() {
use std::fs::File;
use std::io::prelude::*;
let mut file = File::open("example.json").expect("Could not read file");
let file = File::open("example.json");
if file.is_err() {
return;
}
let mut file = file.unwrap();
let mut contents = String::new();
file.read_to_string(&mut contents)
.expect("Could not read data from file");
Expand Down

0 comments on commit 6fe0fe8

Please sign in to comment.