Skip to content

Commit

Permalink
Add is_empty impl to EnvFileBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
sonro committed Jul 31, 2024
1 parent aa9f907 commit ce6e00b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions test_util/src/env_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ impl EnvFileBuilder {
&self.contents
}

/// Returns true when the contents of the builder is empty.
pub fn is_empty(&self) -> bool {
self.contents.is_empty()
}

/// Add a slice of key-value pairs, separated by newlines.
///
/// Includes a trailing newline.
Expand Down
9 changes: 2 additions & 7 deletions test_util/src/tests/env_file_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use super::*;
#[test]
fn new_builds_empty() {
let efb = EnvFileBuilder::new();
assert_contents_empty(efb);
assert!(efb.is_empty());
}

#[test]
fn default_builds_empty() {
let efb = EnvFileBuilder::default();
assert_contents_empty(efb);
assert!(efb.is_empty());
}

#[test]
Expand Down Expand Up @@ -106,11 +106,6 @@ fn from_string() {
assert_contents_str(efb, &create_default_env_file());
}

fn assert_contents_empty(efb: EnvFileBuilder) {
let contents = efb.into_owned_bytes();
assert!(contents.is_empty());
}

fn assert_contents_str(efb: EnvFileBuilder, expected: &str) {
let contents = efb.into_owned_string();
assert_eq!(expected, contents,);
Expand Down

0 comments on commit ce6e00b

Please sign in to comment.