Skip to content

Commit 7d1b26c

Browse files
committed
chore: use indoc for unit tests
1 parent 5ae40f6 commit 7d1b26c

3 files changed

Lines changed: 30 additions & 17 deletions

File tree

rust/operator-binary/src/controller/build/properties/hadoop_policy.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub fn build(overrides: KeyValueConfigOverrides) -> String {
1414

1515
#[cfg(test)]
1616
mod tests {
17+
use indoc::indoc;
18+
1719
use super::*;
1820
use crate::controller::build::properties::test_support::EMPTY_HADOOP_XML;
1921

@@ -26,15 +28,14 @@ mod tests {
2628
fn overrides_are_rendered_as_properties() {
2729
assert_eq!(
2830
build([("security.client.protocol.acl", "*")].into()),
29-
concat!(
30-
"<?xml version=\"1.0\"?>\n",
31-
"<configuration>\n",
32-
" <property>\n",
33-
" <name>security.client.protocol.acl</name>\n",
34-
" <value>*</value>\n",
35-
" </property>\n",
36-
"</configuration>"
37-
)
31+
indoc! {r#"
32+
<?xml version="1.0"?>
33+
<configuration>
34+
<property>
35+
<name>security.client.protocol.acl</name>
36+
<value>*</value>
37+
</property>
38+
</configuration>"#}
3839
);
3940
}
4041
}

rust/operator-binary/src/controller/build/properties/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ mod tests {
7272

7373
#[cfg(test)]
7474
pub(crate) mod test_support {
75+
use indoc::indoc;
7576
use stackable_operator::{
7677
commons::networking::DomainName, utils::cluster_info::KubernetesClusterInfo,
7778
};
7879

7980
use crate::{controller::ValidatedCluster, test_support::deserialize_and_validate_cluster};
8081

8182
/// The rendered output of an empty Hadoop-XML configuration (no entries).
82-
pub const EMPTY_HADOOP_XML: &str = concat!(
83-
"<?xml version=\"1.0\"?>\n",
84-
"<configuration>\n",
85-
"</configuration>"
86-
);
83+
pub const EMPTY_HADOOP_XML: &str = indoc! {r#"
84+
<?xml version="1.0"?>
85+
<configuration>
86+
</configuration>"#};
8787

8888
/// A minimal three-role HdfsCluster used to drive the per-file builder tests.
8989
pub const MINIMAL_HDFS_YAML: &str = r#"

rust/operator-binary/src/controller/build/properties/security_properties.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,41 @@ pub fn build(overrides: KeyValueConfigOverrides) -> Result<String, PropertiesWri
2929

3030
#[cfg(test)]
3131
mod tests {
32+
use indoc::indoc;
33+
3234
use super::*;
3335

3436
#[test]
3537
fn injects_recommended_dns_cache_ttls() {
3638
assert_eq!(
3739
build(KeyValueConfigOverrides::default()).unwrap(),
38-
"networkaddress.cache.negative.ttl=0\nnetworkaddress.cache.ttl=30\n"
40+
indoc! {"
41+
networkaddress.cache.negative.ttl=0
42+
networkaddress.cache.ttl=30
43+
"}
3944
);
4045
}
4146

4247
#[test]
4348
fn user_overrides_win_over_injected_defaults() {
4449
assert_eq!(
4550
build([("networkaddress.cache.ttl", "60")].into()).unwrap(),
46-
"networkaddress.cache.negative.ttl=0\nnetworkaddress.cache.ttl=60\n"
51+
indoc! {"
52+
networkaddress.cache.negative.ttl=0
53+
networkaddress.cache.ttl=60
54+
"}
4755
);
4856
}
4957

5058
#[test]
5159
fn extra_overrides_are_appended() {
5260
assert_eq!(
5361
build([("foo.bar", "baz")].into()).unwrap(),
54-
"foo.bar=baz\nnetworkaddress.cache.negative.ttl=0\nnetworkaddress.cache.ttl=30\n"
62+
indoc! {"
63+
foo.bar=baz
64+
networkaddress.cache.negative.ttl=0
65+
networkaddress.cache.ttl=30
66+
"}
5567
);
5668
}
5769
}

0 commit comments

Comments
 (0)