1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2025-04-07 09:41:50 +00:00

style: enforce ALL_MODULES ordering in test (#2837)

* style: enforce ALL_MODULES ordering in test

* use unstable sort

* use copied instead of dereferencing in iterator
This commit is contained in:
Andrew Houts 2021-07-02 11:00:46 -07:00 committed by GitHub
parent a123df24dc
commit 2acd98248b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,6 @@ use std::fmt;
use std::time::Duration; use std::time::Duration;
// List of all modules // List of all modules
// Keep these ordered alphabetically.
// Default ordering is handled in configs/starship_root.rs // Default ordering is handled in configs/starship_root.rs
pub const ALL_MODULES: &[&str] = &[ pub const ALL_MODULES: &[&str] = &[
"aws", "aws",
@ -16,6 +15,7 @@ pub const ALL_MODULES: &[&str] = &[
"cmake", "cmake",
"cmd_duration", "cmd_duration",
"conda", "conda",
"crystal",
"dart", "dart",
"deno", "deno",
"directory", "directory",
@ -23,8 +23,8 @@ pub const ALL_MODULES: &[&str] = &[
"dotnet", "dotnet",
"elixir", "elixir",
"elm", "elm",
"erlang",
"env_var", "env_var",
"erlang",
"gcloud", "gcloud",
"git_branch", "git_branch",
"git_commit", "git_commit",
@ -35,7 +35,6 @@ pub const ALL_MODULES: &[&str] = &[
"hg_branch", "hg_branch",
"hostname", "hostname",
"java", "java",
"scala",
"jobs", "jobs",
"julia", "julia",
"kotlin", "kotlin",
@ -50,24 +49,24 @@ pub const ALL_MODULES: &[&str] = &[
"openstack", "openstack",
"package", "package",
"perl", "perl",
"php",
"purescript", "purescript",
"python", "python",
"rlang",
"red", "red",
"rlang",
"ruby", "ruby",
"crystal",
"rust", "rust",
"php", "scala",
"swift",
"terraform",
"shell", "shell",
"shlvl", "shlvl",
"singularity", "singularity",
"status", "status",
"swift",
"terraform",
"time", "time",
"username", "username",
"vcsh",
"vagrant", "vagrant",
"vcsh",
"vlang", "vlang",
"zig", "zig",
]; ];
@ -177,6 +176,13 @@ fn ansi_strings_modified(ansi_strings: Vec<ANSIString>, shell: Shell) -> Vec<ANS
mod tests { mod tests {
use super::*; use super::*;
#[test]
fn test_all_modules_is_in_alphabetical_order() {
let mut sorted_modules: Vec<&str> = ALL_MODULES.iter().copied().collect();
sorted_modules.sort_unstable();
assert_eq!(sorted_modules.as_slice(), ALL_MODULES);
}
#[test] #[test]
fn test_module_is_empty_with_no_segments() { fn test_module_is_empty_with_no_segments() {
let name = "unit_test"; let name = "unit_test";