From 945b0db85b2e36f7577fdf5a44fec38c70f7785a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 15 Jul 2024 14:20:44 -0400 Subject: [PATCH] tests: Use indoc This makes string literals way more legible. Prep for more tests. Signed-off-by: Colin Walters --- Cargo.lock | 1 + lib/Cargo.toml | 1 + lib/src/generator.rs | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 38787fe63..8cf115b49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,6 +180,7 @@ dependencies = [ "gvariant", "hex", "indicatif", + "indoc", "libc", "liboverdrop", "libsystemd", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 6afd0b2d0..d8a64b0d7 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -47,6 +47,7 @@ xshell = { version = "0.2.6", optional = true } uuid = { version = "1.8.0", features = ["v4"] } [dev-dependencies] +indoc = "2.0.5" similar-asserts = { version = "1.5.0" } [features] diff --git a/lib/src/generator.rs b/lib/src/generator.rs index 78ef3647e..086723ea9 100644 --- a/lib/src/generator.rs +++ b/lib/src/generator.rs @@ -129,21 +129,21 @@ fn test_generator_fstab() -> Result<()> { #[test] fn test_generator_fstab_idempotent() -> Result<()> { - let anaconda_fstab = "\n\ -#\n\ -# /etc/fstab\n\ -# Created by anaconda on Tue Mar 19 12:24:29 2024\n\ -#\n\ -# Accessible filesystems, by reference, are maintained under '/dev/disk/'.\n\ -# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.\n\ -#\n\ -# After editing this file, run 'systemctl daemon-reload' to update systemd\n\ -# units generated from this file.\n\ -#\n\ -# Updated by bootc-fstab-edit.service\n\ -UUID=715be2b7-c458-49f2-acec-b2fdb53d9089 / xfs ro 0 0\n\ -UUID=341c4712-54e8-4839-8020-d94073b1dc8b /boot xfs defaults 0 0\n\ -"; + let anaconda_fstab = indoc::indoc! { " +# +# /etc/fstab +# Created by anaconda on Tue Mar 19 12:24:29 2024 +# +# Accessible filesystems, by reference, are maintained under '/dev/disk/'. +# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. +# +# After editing this file, run 'systemctl daemon-reload' to update systemd +# units generated from this file. +# +# Updated by bootc-fstab-edit.service +UUID=715be2b7-c458-49f2-acec-b2fdb53d9089 / xfs ro 0 0 +UUID=341c4712-54e8-4839-8020-d94073b1dc8b /boot xfs defaults 0 0 +" }; let tempdir = fixture()?; let unit_dir = &tempdir.open_dir("run/systemd/system")?;