Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert_contains! macro #322

Merged
merged 5 commits into from
Feb 22, 2022
Merged

Add assert_contains! macro #322

merged 5 commits into from
Feb 22, 2022

Conversation

Malax
Copy link
Member

@Malax Malax commented Feb 15, 2022

Add assert_contains! macro for asserting patterns in strings. Useful for libcnb-test users that commonly want to match the output of a pack run.

RustDoc

Asserts that left contains right.

Commonly used when asserting pack output in integration tests. Expands to a str::contains
call and logs left (in unescaped and escaped form) as well as right on failure.

Example

let output = "Hello World!\nHello Integration Test!";
assert_contains!(output, "Integration");

Closes GUS-W-10701312

Copy link
Member

@edmorley edmorley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this! I suspect we'll be using it a lot :-)

libcnb-test/src/macros.rs Show resolved Hide resolved
libcnb-test/src/macros.rs Show resolved Hide resolved
libcnb-test/src/macros.rs Show resolved Hide resolved
@Malax Malax merged commit 87b4376 into main Feb 22, 2022
@Malax Malax deleted the malax/assert_contains branch February 22, 2022 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants