Skip to content

Commit

Permalink
Merge pull request #157 from Screenly/fix/null_title
Browse files Browse the repository at this point in the history
Fix: accepting null titles in setting response.
  • Loading branch information
korvyashka authored Mar 22, 2024
2 parents 6ff4df5 + d0c2f8a commit 425420f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 50 deletions.
60 changes: 34 additions & 26 deletions src/commands/edge_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl EdgeAppCommand {
settings: vec![
Setting {
name: "secret_word".to_string(),
title: "secret title".to_string(),
title: Some("secret title".to_string()),
type_: SettingType::Secret,
default_value: None,
optional: true,
Expand All @@ -110,7 +110,7 @@ impl EdgeAppCommand {
},
Setting {
name: "greeting".to_string(),
title: "greeting title".to_string(),
title: Some("greeting title".to_string()),
type_: SettingType::String,
default_value: Some("Unknown".to_string()),
optional: true,
Expand Down Expand Up @@ -728,7 +728,7 @@ impl EdgeAppCommand {
const SLEEP_TIME: u64 = 2;
const MAX_WAIT_TIME: u64 = 1000; // 1000 seconds - it could take a while for assets to process

let mut pb: Option<ProgressBar> = Option::None;
let mut pb: Option<ProgressBar> = None;
let mut assets_to_process = 0;
let start_time = Instant::now();

Expand Down Expand Up @@ -1153,7 +1153,7 @@ mod tests {
vec![
Setting {
name: "greeting".to_string(),
title: "greeting title".to_string(),
title: Some("greeting title".to_string()),
type_: SettingType::String,
default_value: Some("Unknown".to_string()),
optional: true,
Expand All @@ -1163,7 +1163,7 @@ mod tests {
},
Setting {
name: "secret_word".to_string(),
title: "secret title".to_string(),
title: Some("secret title".to_string()),
type_: SettingType::Secret,
default_value: None,
optional: true,
Expand Down Expand Up @@ -2095,7 +2095,7 @@ mod tests {
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -2104,7 +2104,7 @@ mod tests {
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -2198,6 +2198,14 @@ mod tests {
"optional": true,
"help_text": "For how long to display the map overlay every time the rover has moved to a new position.".to_string(),
"is_global": false,
}, {
"name": "isetting".to_string(),
"type": SettingType::String,
"default_value": "5".to_string(),
"title": null,
"optional": true,
"help_text": "Some text".to_string(),
"is_global": false,
}]));
});

Expand Down Expand Up @@ -2400,7 +2408,7 @@ mod tests {
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -2409,7 +2417,7 @@ mod tests {
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -2473,7 +2481,7 @@ mod tests {
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -2482,7 +2490,7 @@ mod tests {
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -2546,7 +2554,7 @@ mod tests {
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -2555,7 +2563,7 @@ mod tests {
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -2723,7 +2731,7 @@ mod tests {
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("yes".to_string()),
is_global: false,
Expand All @@ -2732,7 +2740,7 @@ mod tests {
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -2774,7 +2782,7 @@ settings:
Setting {
name: "excluded_setting".to_string(),
type_: SettingType::Secret,
title: "excluded title".to_string(),
title: Some("excluded title".to_string()),
optional: false,
default_value: None,
is_global: false,
Expand All @@ -2783,7 +2791,7 @@ settings:
Setting {
name: "included_setting".to_string(),
type_: SettingType::String,
title: "included title".to_string(),
title: Some("included title".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -2810,7 +2818,7 @@ settings:
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -2819,7 +2827,7 @@ settings:
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -3236,7 +3244,7 @@ settings:
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -3245,7 +3253,7 @@ settings:
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -3290,7 +3298,7 @@ settings:
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -3299,7 +3307,7 @@ settings:
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -3408,7 +3416,7 @@ settings:
Setting {
name: "asetting".to_string(),
type_: SettingType::String,
title: "atitle".to_string(),
title: Some("atitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand All @@ -3417,7 +3425,7 @@ settings:
Setting {
name: "nsetting".to_string(),
type_: SettingType::String,
title: "ntitle".to_string(),
title: Some("ntitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: false,
Expand Down Expand Up @@ -3546,7 +3554,7 @@ settings:
let setting = Setting {
name: "ssetting".to_string(),
type_: SettingType::Secret,
title: "stitle".to_string(),
title: Some("stitle".to_string()),
optional: false,
default_value: Some("".to_string()),
is_global: true,
Expand Down
20 changes: 10 additions & 10 deletions src/commands/edge_app_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ mod tests {
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down Expand Up @@ -274,7 +274,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down Expand Up @@ -320,7 +320,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down Expand Up @@ -360,7 +360,7 @@ settings:
app_id: Some("test_app".to_string()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down Expand Up @@ -397,7 +397,7 @@ settings:
app_id: Some("test_app".to_string()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand All @@ -422,7 +422,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand All @@ -448,7 +448,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand All @@ -474,7 +474,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down Expand Up @@ -681,7 +681,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down Expand Up @@ -727,7 +727,7 @@ settings:
entrypoint: Some("entrypoint.html".to_owned()),
settings: vec![Setting {
name: "username".to_string(),
title: "username title".to_string(),
title: Some("username title".to_string()),
type_: SettingType::String,
default_value: Some("stranger".to_string()),
optional: true,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/edge_app_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct Setting {
#[serde(skip_serializing_if = "Option::is_none")]
pub default_value: Option<String>,
#[serde(default)]
pub title: String,
pub title: Option<String>,
#[serde(skip)]
pub name: String,
pub optional: bool,
Expand Down Expand Up @@ -103,7 +103,7 @@ where
setting.default_value = value.as_str().map(|s| s.to_string());
}
"title" => {
setting.title = value.as_str().expect("Failed to parse title.").to_string();
setting.title = value.as_str().map(|s| s.to_string());
}
"optional" => {
setting.optional = value.as_bool().expect("Failed to parse optional.")
Expand Down
Loading

0 comments on commit 425420f

Please sign in to comment.