Skip to content

Commit

Permalink
Add tests for serializing author service type
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-richter committed Oct 22, 2024
1 parent f783eec commit 1f5654e
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/models/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,49 @@ mod tests {
);
assert_eq!(under_test.variable_type, VariableType::String,);
}

#[test]
fn serialize_author_service_environment_variable() {
let variable: EnvironmentVariable = EnvironmentVariable {
name: String::from("authorVarName"),
variable_type: VariableType::String,
service: EnvironmentVariableServiceType::All,
value: Some(String::from("authorVarValue"))
};
let under_test: String = serde_json::to_string(&variable).unwrap();
assert_eq!(
under_test,
"{\"name\":\"authorVarName\",\"value\":\"authorVarValue\",\"type\":\"string\"}",
);
}

#[test]
fn serialize_publish_service_environment_variable() {
let variable: EnvironmentVariable = EnvironmentVariable {
name: String::from("publishVarName"),
variable_type: VariableType::SecretString,
service: EnvironmentVariableServiceType::Publish,
value: Some(String::from("publishValue"))
};
let under_test: String = serde_json::to_string(&variable).unwrap();
assert_eq!(
under_test,
"{\"name\":\"publishVarName\",\"value\":\"publishValue\",\"type\":\"secretString\",\"service\":\"publish\"}",
);
}

#[test]
fn serialize_preview_service_environment_variable() {
let variable: EnvironmentVariable = EnvironmentVariable {
name: String::from("previewVarName"),
variable_type: VariableType::String,
service: EnvironmentVariableServiceType::Preview,
value: Some(String::from("previewValue"))
};
let under_test: String = serde_json::to_string(&variable).unwrap();
assert_eq!(
under_test,
"{\"name\":\"previewVarName\",\"value\":\"previewValue\",\"type\":\"string\",\"service\":\"preview\"}",
);
}
}

0 comments on commit 1f5654e

Please sign in to comment.