aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-10-30 16:05:01 +0100
committerGitHub <noreply@github.com>2023-10-30 16:05:01 +0100
commit42292c2d114f55d39c4a43570be79888c0362f0f (patch)
tree28f3d421617bf3cf94ec77904347f257bd495c14 /src-tauri
parentb593e74eaeff986e23ff015722ca067272c19d99 (diff)
downloadFlightCore-42292c2d114f55d39c4a43570be79888c0362f0f.tar.gz
FlightCore-42292c2d114f55d39c4a43570be79888c0362f0f.zip
test: Add unit tests for rc number conversion (#652)
Adds unit test for converting release candidate numbers
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/src/util.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs
index 0b91da48..6466e2b8 100644
--- a/src-tauri/src/util.rs
+++ b/src-tauri/src/util.rs
@@ -234,3 +234,36 @@ pub fn convert_release_candidate_number(version_number: String) -> String {
// Doesn't work for larger numbers, e.g. `v1.9.2-rc11` -> `v1.9.2011` (should be `v1.9.211`)
version_number.replace("-rc", "0").replace(".00", ".")
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_basic_release_candidate_number_conversion() {
+ let input = "v1.2.3-rc4".to_string();
+ let output = convert_release_candidate_number(input);
+ let expected_output = "v1.2.304";
+ assert_eq!(output, expected_output);
+ }
+
+ #[test]
+ fn test_leading_zero_release_candidate_number_conversion() {
+ let input = "v1.2.0-rc3".to_string();
+ let output = convert_release_candidate_number(input);
+ let expected_output = "v1.2.3";
+ assert_eq!(output, expected_output);
+ }
+
+ #[test]
+ fn test_double_patch_digit_release_candidate_number_conversion() {
+ // let input = "v1.2.34-rc5".to_string();
+ // let output = convert_release_candidate_number(input);
+ // let expected_output = "v1.2.3405";
+ let input = "v1.19.10-rc1".to_string();
+ let output = convert_release_candidate_number(input);
+ let expected_output = "v1.19.1001";
+
+ assert_eq!(output, expected_output);
+ }
+}