summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Büsch <antoine.busch@gmail.com>2018-10-01 14:11:09 +1000
committerAntoine Büsch <antoine.busch@gmail.com>2018-10-01 14:11:09 +1000
commit1da113ce0e607ec6a3099193f40b6efa7289ed63 (patch)
tree7995d6075f4aa0928488b1fe58b85ed657dad48e
parent99fc8b45d7ce71377fb992d2ec215eb19bc77ab1 (diff)
Fix tests
-rw-r--r--src/builder.rs28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/builder.rs b/src/builder.rs
index 3dfe1bf..aa5d178 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -329,9 +329,24 @@ impl ContainerOptions {
}
/// serialize options as a string. returns None if no options are defined
- // pub fn serialize(&self) -> Result<String> {
- // Ok(serde_json::to_string(&self.to_json())?)
- // }
+ pub fn serialize(&self) -> Result<String> {
+ Ok(serde_json::to_string(&self.to_json())?)
+ }
+
+ fn to_json(&self) -> Value {
+ let mut body_members = Map::new();
+ // The HostConfig element gets initialized to an empty object,
+ // for backward compatibility.
+ body_members.insert(
+ "HostConfig".to_string(),
+ Value::Object(Map::new()),
+ );
+ let mut body = Value::Object(body_members);
+ self.parse_from(&self.params, &mut body);
+ self.parse_from(&self.params_list, &mut body);
+ self.parse_from(&self.params_hash, &mut body);
+ body
+ }
pub fn parse_from<'a, K, V>(
&self,
@@ -1128,6 +1143,7 @@ impl ContainerConnectionOptions {
#[cfg(test)]
mod tests {
+ use serde_json;
use super::ContainerOptionsBuilder;
#[test]
@@ -1185,8 +1201,10 @@ mod tests {
.restart_policy("on-failure", 10)
.build();
- assert_eq!(r#"{"HostConfig":{"RestartPolicy":{"MaximumRetryCount":10,"Name":"on-failure"}},"Image":"test_image"}"#,
- options.serialize().unwrap());
+ assert_eq!(
+ r#"{"HostConfig":{"RestartPolicy":{"MaximumRetryCount":10,"Name":"on-failure"}},"Image":"test_image"}"#,
+ options.serialize().unwrap()
+ );
options = ContainerOptionsBuilder::new("test_image")
.restart_policy("always", 0)