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

Make expected result string in unit tests more readable #2412

Closed
WinkerDu opened this issue May 2, 2022 · 0 comments · Fixed by #2413
Closed

Make expected result string in unit tests more readable #2412

WinkerDu opened this issue May 2, 2022 · 0 comments · Fixed by #2413

Comments

@WinkerDu
Copy link
Contributor

WinkerDu commented May 2, 2022

Some unit tests in DataFusion organize expected result string vector in one line, like sql::union::union_distinct do

#[tokio::test]
async fn union_distinct() -> Result<()> {
    let ctx = SessionContext::new();
    let sql = "SELECT 1 as x UNION SELECT 1 as x";
    let actual = execute_to_batches(&ctx, sql).await;
    let expected = vec!["+---+", "| x |", "+---+", "| 1 |", "+---+"];
    assert_batches_eq!(expected, &actual);
    Ok(())
}

We can separate the expected result string vector into multiple line to make it more readable and easier to follow, by adding a #[rustfmt::skip] tag to skip fmt check as following code

#[tokio::test]
async fn union_distinct() -> Result<()> {
    let ctx = SessionContext::new();
    let sql = "SELECT 1 as x UNION SELECT 1 as x";
    let actual = execute_to_batches(&ctx, sql).await;
    #[rustfmt::skip]
    let expected = vec![
        "+---+",
        "| x |",
        "+---+",
        "| 1 |",
        "+---+"
    ];
    assert_batches_eq!(expected, &actual);
    Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant