summaryrefslogtreecommitdiff
path: root/server/common/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/common/src/tests.rs')
-rw-r--r--server/common/src/tests.rs230
1 files changed, 230 insertions, 0 deletions
diff --git a/server/common/src/tests.rs b/server/common/src/tests.rs
index 5a02119..fc4d7aa 100644
--- a/server/common/src/tests.rs
+++ b/server/common/src/tests.rs
@@ -5,6 +5,7 @@ use tokio::sync::OnceCell;
use crate::fs_utils;
use crate::git;
+use crate::grit;
#[tokio::test]
async fn test_fs_utils_create_dir_allow_existing() {
@@ -285,3 +286,232 @@ async fn test_git_bare_delete_branch() {
assert!(repo.delete_branch("other").await.is_ok());
assert!(repo.delete_branch("does-not-exist").await.is_err());
}
+
+#[tokio::test]
+async fn test_grit_parse_base() {
+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/testdata/grit/base.grd");
+ let grit = grit::parse_grit(path).await.unwrap();
+ assert_eq!(
+ grit,
+ grit::Grit {
+ current_release: 1,
+ latest_public_release: 0,
+ outputs: grit::Outputs {
+ output: vec![
+ grit::IfOutput::Output(
+ grit::Output {
+ filename: "values/strings.xml".to_string(),
+ output_type: "android".to_string(),
+ lang: "en".to_string(),
+ },
+ ),
+ grit::IfOutput::Output(
+ grit::Output {
+ filename: "values-en-rGB/strings.xml".to_string(),
+ output_type: "android".to_string(),
+ lang: "en-GB".to_string(),
+ },
+ ),
+ grit::IfOutput::Output(
+ grit::Output {
+ filename: "values-my/strings.xml".to_string(),
+ output_type: "android".to_string(),
+ lang: "my".to_string(),
+ },
+ ),
+ grit::IfOutput::If {
+ expr: "not pp_if('zawgyi_encoding')".to_string(),
+ output: vec![
+ grit::Output {
+ filename: "values-my-rZG/strings.xml".to_string(),
+ output_type: "android".to_string(),
+ lang: "my-ZG".to_string(),
+ },
+ ],
+ },
+ grit::IfOutput::Output(
+ grit::Output {
+ filename: "values-sv/strings.xml".to_string(),
+ output_type: "android".to_string(),
+ lang: "sv".to_string(),
+ },
+ ),
+ ],
+ },
+ translations: grit::Translations {
+ file: vec![
+ grit::IfFile::File(
+ grit::File {
+ path: "translations/base_en_gb.xlf".to_string(),
+ lang: "en-GB".to_string(),
+ },
+ ),
+ grit::IfFile::If {
+ expr: "pp_if('zawgyi_encoding')".to_string(),
+ file: vec![
+ grit::File {
+ path: "translations/base_my-Zawgyi.xlf".to_string(),
+ lang: "my".to_string(),
+ },
+ ],
+ },
+ grit::IfFile::If {
+ expr: "not pp_if('zawgyi_encoding')".to_string(),
+ file: vec![
+ grit::File {
+ path: "translations/base_my.xlf".to_string(),
+ lang: "my".to_string(),
+ },
+ grit::File {
+ path: "translations/base_my-Zawgyi.xlf".to_string(),
+ lang: "my-ZG".to_string(),
+ },
+ ],
+ },
+ grit::IfFile::File(
+ grit::File {
+ path: "translations/base_sv.xlf".to_string(),
+ lang: "sv".to_string(),
+ },
+ ),
+ ],
+ },
+ release: grit::Release {
+ allow_pseudo: false,
+ seq: 1,
+ messages: grit::Messages {
+ fallback_to_english: true,
+ messages: vec![
+ grit::IfMessagePart::If {
+ expr: "pp_ifdef('include_extra')".to_string(),
+ message: vec![
+ grit::MessagePart::Part(
+ grit::PartRef {
+ file: "extra.grdp".to_string(),
+ },
+ ),
+ ],
+ },
+ grit::IfMessagePart::Message(
+ grit::Message {
+ desc: "Title which is shown on the main bookmarks view.".to_string(),
+ name: "IDS_BOOKMARKS_FRAGMENT_TITLE".to_string(),
+ internal_comment: Some("section(bookmarks)".to_string()),
+ meaning: None,
+ content: vec![
+ grit::TextPlaceholder::Text("Bookmarks".to_string()),
+ ],
+ },
+ ),
+ grit::IfMessagePart::Message(
+ grit::Message {
+ desc: "Generic welcome string.".to_string(),
+ name: "IDS_GENERIC_WELCOME".to_string(),
+ internal_comment: Some("section(eula)".to_string()),
+ meaning: None,
+ content: vec![
+ grit::TextPlaceholder::Text("Welcome to ".to_string()),
+ grit::TextPlaceholder::Placeholder {
+ name: "STRING".to_string(),
+ content: "%1$s".to_string(),
+ example: Some("Opera".to_string()),
+ },
+ ],
+ },
+ ),
+ grit::IfMessagePart::Message(
+ grit::Message {
+ desc: "First startup information about the license and privacy terms.".to_string(),
+ name: "IDS_START_TERMS".to_string(),
+ internal_comment: None,
+ meaning: None,
+ content: vec![
+ grit::TextPlaceholder::Text(
+ "By using this application you are agreeing to Opera's ".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "TOS_BEGIN".to_string(),
+ content: "<tos>".to_string(),
+ example: None,
+ },
+ grit::TextPlaceholder::Text(
+ "Terms of Service".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "TOS_END".to_string(),
+ content: "</tos>".to_string(),
+ example: None,
+ },
+ grit::TextPlaceholder::Text(
+ ". Also, you can learn how Opera handles and protects your data in our ".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "PRIVACY_BEGIN".to_string(),
+ content: "<privacy>".to_string(),
+ example: None,
+ },
+ grit::TextPlaceholder::Text(
+ "Privacy Statement".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "PRIVACY_END".to_string(),
+ content: "</privacy>".to_string(),
+ example: None,
+ },
+ grit::TextPlaceholder::Text(
+ ".".to_string(),
+ ),
+ ],
+ },
+ ),
+ grit::IfMessagePart::Message(
+ grit::Message {
+ desc: "Message which is shown when one or more folders have been deleted from the bookmark list.".to_string(),
+ name: "IDS_BOOKMARKS_FOLDERS_DELETED".to_string(),
+ internal_comment: None,
+ meaning: None,
+ content: vec![
+ grit::TextPlaceholder::Text(
+ "{BOOKMARKS, plural,\n one {".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "COUNT".to_string(),
+ content: "%1$d".to_string(),
+ example: Some("1".to_string()),
+ },
+ grit::TextPlaceholder::Text(
+ " folder deleted}\n few {".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "COUNT".to_string(),
+ content: "%1$d".to_string(),
+ example: Some("15".to_string()),
+ },
+ grit::TextPlaceholder::Text(
+ " folders deleted}\n many {".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "COUNT".to_string(),
+ content: "%1$d".to_string(),
+ example: Some("100".to_string()),
+ },
+ grit::TextPlaceholder::Text(
+ " folders deleted}\n other {".to_string(),
+ ),
+ grit::TextPlaceholder::Placeholder {
+ name: "COUNT".to_string(),
+ content: "%1$d".to_string(),
+ example: Some("42".to_string()),
+ },
+ grit::TextPlaceholder::Text(
+ " folders deleted}}".to_string(),
+ ),
+ ],
+ },
+ ),
+ ],
+ },
+ },
+ },
+ )
+}