From f710b68a3e83efa8155fc96034ca075a6ce2d50a Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 29 Apr 2023 23:56:48 -0700 Subject: [PATCH] Fix broken tests, add testing script --- crates/lib/files/filesys/src/directory_exists.rs | 4 ++-- crates/lib/files/filesys/src/file_exists.rs | 4 ++-- crates/lib/files/filesys/src/file_size.rs | 2 +- .../files/hashing/src/sha256/sha256_hash_file.rs | 4 ++-- .../lib/files/mimetypes/src/mimetype_for_file.rs | 2 +- crates/lib/subprocess_common/src/docker_options.rs | 4 ++-- crates/lib/tts_common/src/clean_symbols.rs | 2 +- execute_tests.sh | 14 ++++++++++++++ 8 files changed, 25 insertions(+), 11 deletions(-) create mode 100755 execute_tests.sh diff --git a/crates/lib/files/filesys/src/directory_exists.rs b/crates/lib/files/filesys/src/directory_exists.rs index 471c4d3bf7..db48c13519 100644 --- a/crates/lib/files/filesys/src/directory_exists.rs +++ b/crates/lib/files/filesys/src/directory_exists.rs @@ -33,8 +33,8 @@ mod tests { assert_eq!(true, directory_exists(PathBuf::from("/"))); // Other directories - assert_eq!(true, directory_exists("../../../test_data/audio/flac")); - assert_eq!(true, directory_exists(PathBuf::from("../../../test_data/audio/flac"))); + assert_eq!(true, directory_exists("../../../../test_data/audio/flac")); + assert_eq!(true, directory_exists(PathBuf::from("../../../../test_data/audio/flac"))); } #[test] diff --git a/crates/lib/files/filesys/src/file_exists.rs b/crates/lib/files/filesys/src/file_exists.rs index ee953d3190..ce8ef5479a 100644 --- a/crates/lib/files/filesys/src/file_exists.rs +++ b/crates/lib/files/filesys/src/file_exists.rs @@ -18,8 +18,8 @@ mod tests { #[test] fn test_file_exists() { - assert_eq!(true, file_exists("../../../test_data/audio/flac/zelda_ocarina_small_item.flac")); - assert_eq!(true, file_exists(PathBuf::from("../../../test_data/audio/flac/zelda_ocarina_small_item.flac"))); + assert_eq!(true, file_exists("../../../../test_data/audio/flac/zelda_ocarina_small_item.flac")); + assert_eq!(true, file_exists(PathBuf::from("../../../../test_data/audio/flac/zelda_ocarina_small_item.flac"))); } #[test] diff --git a/crates/lib/files/filesys/src/file_size.rs b/crates/lib/files/filesys/src/file_size.rs index 2bd59dd808..e922f98287 100644 --- a/crates/lib/files/filesys/src/file_size.rs +++ b/crates/lib/files/filesys/src/file_size.rs @@ -23,7 +23,7 @@ mod tests { fn test_file(path_from_repo_root: &str) -> PathBuf { // https://doc.rust-lang.org/cargo/reference/environment-variables.html let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path.push(format!("../../../{}", path_from_repo_root)); + path.push(format!("../../../../{}", path_from_repo_root)); path } diff --git a/crates/lib/files/hashing/src/sha256/sha256_hash_file.rs b/crates/lib/files/hashing/src/sha256/sha256_hash_file.rs index 64e3b2e65e..546c3e2026 100644 --- a/crates/lib/files/hashing/src/sha256/sha256_hash_file.rs +++ b/crates/lib/files/hashing/src/sha256/sha256_hash_file.rs @@ -21,7 +21,7 @@ pub mod tests { fn test_sha256_hash_file_1() { assert_eq!( "8d593e85d8c30620b57af0734c010a8cd00083a5a2ffd1ffb91f2c9e85d8535d", - sha256_hash_file("../../../test_data/audio/aac/golden_sun_elemental_stars_cyanne.aac") + sha256_hash_file("../../../../test_data/audio/aac/golden_sun_elemental_stars_cyanne.aac") .unwrap()); } @@ -29,7 +29,7 @@ pub mod tests { fn test_sha256_hash_file_2() { assert_eq!( "452812e5b5269f74b13175e0ef739255ee094f55c9d45a9336ed129cf7c66f8e", - sha256_hash_file("../../../test_data/video/webm/laser_pong.webm") + sha256_hash_file("../../../../test_data/video/webm/laser_pong.webm") .unwrap()); } } diff --git a/crates/lib/files/mimetypes/src/mimetype_for_file.rs b/crates/lib/files/mimetypes/src/mimetype_for_file.rs index 79c39374b0..75576ca7b6 100644 --- a/crates/lib/files/mimetypes/src/mimetype_for_file.rs +++ b/crates/lib/files/mimetypes/src/mimetype_for_file.rs @@ -23,7 +23,7 @@ mod tests { fn test_file(path_from_repo_root: &str) -> PathBuf { // https://doc.rust-lang.org/cargo/reference/environment-variables.html let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - path.push(format!("../../../{}", path_from_repo_root)); + path.push(format!("../../../../{}", path_from_repo_root)); path } diff --git a/crates/lib/subprocess_common/src/docker_options.rs b/crates/lib/subprocess_common/src/docker_options.rs index 98157e38ca..071521a615 100644 --- a/crates/lib/subprocess_common/src/docker_options.rs +++ b/crates/lib/subprocess_common/src/docker_options.rs @@ -99,7 +99,7 @@ mod tests { #[test] fn test_command() { let command = DockerOptions { - image_name: "MY_IMAAGE".to_string(), + image_name: "MY_IMAGE".to_string(), maybe_bind_mount: Some(DockerFilesystemMount { local_filesystem: "/local".to_string(), container_filesystem: "/container".to_string(), @@ -111,7 +111,7 @@ mod tests { maybe_gpu: Some(DockerGpu::All), }; - assert_eq!("docker run --rm --env FOO=1,BAR=2 --mount type=bind,source=/local,target=/container --gpus all MY_IMAAGE /bin/bash -c \"echo wat\"", + assert_eq!("docker run --rm --env FOO=1 --env BAR=2 --mount type=bind,source=/local,target=/container --gpus all MY_IMAGE /bin/bash -c \"echo wat\"", command.to_command_string("echo wat")); } } diff --git a/crates/lib/tts_common/src/clean_symbols.rs b/crates/lib/tts_common/src/clean_symbols.rs index d52e061e46..1391c04e72 100644 --- a/crates/lib/tts_common/src/clean_symbols.rs +++ b/crates/lib/tts_common/src/clean_symbols.rs @@ -173,7 +173,7 @@ mod tests { use once_cell::sync::Lazy; use crate::clean_symbols::clean_symbols; - const TIME_BOMB_EPOCH_STR : &'static str = "2023-04-01T00:00:00.00Z"; + const TIME_BOMB_EPOCH_STR : &'static str = "2023-06-01T00:00:00.00Z"; static TIME_BOMB_EPOCH: Lazy> = Lazy::new(|| { let datetime = DateTime::parse_from_rfc3339(TIME_BOMB_EPOCH_STR) diff --git a/execute_tests.sh b/execute_tests.sh new file mode 100755 index 0000000000..59c7aa95c7 --- /dev/null +++ b/execute_tests.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo 'Running tests...' + +# TODO: Fix 'fakeyou_client' and 'billing_component' +# TODO: Run 'sqlite_queries' and 'aichatbot-sidecar' after postgres migrations + +cargo test \ + --workspace \ + --exclude sqlite_queries \ + --exclude aichatbot-sidecar \ + --exclude fakeyou_client \ + --exclude billing_component +